<?php
$sql = 'SELECT gamedate, gametime, homeschool, visitorschool FROM my_table WHERE WEEKOFYEAR(gamedate)=WEEKOFYEAR(NOW()) ORDER BY gamedate';
$result = mysql_query($sql, $link);
if (!$result) {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
if(mysql_num_rows($result)>0) {
?>
<table style="width: 300px; padding: 0; margin-left: -16px;" cellpadding="7px">
<tbody>
<tr><td valign="top"><img src="images/cobrasschedule.png"/></td></tr>
<?php
mysql_data_seek($result, 0);
$day = ' ';
while ($row = mysql_fetch_assoc($result)) {
if (date('l, F d, Y', strtotime($row['gamedate'])) !== $day) {
$day=date('l, F d, Y', strtotime($row['gamedate']));
?>
<tr>
<td colspan="2" style="background-color:#D3BC9A; color:white;text-transform:uppercase; padding-left:25px;"><strong><?= $day?></strong></td>
</tr>
<?php } ?>
<tr>
<?php if ($row['sporttype'] == 'Baseball'): ?>
<td colspan="2" style="background-color:#D3BC9A; color:white;text-transform:uppercase; padding-left:25px;"><strong>BASEBALL</strong></td>
<?php elseif ($row['sporttype'] == 'MBasketball'): ?>
<td colspan="2" style="background-color:#D3BC9A; color:white;text-transform:uppercase; padding-left:25px;"><strong>MEN'S BASKETBALL</strong></td>
<?php elseif ($row['sporttype'] == 'Equine'): ?>
<td colspan="2" style="background-color:#D3BC9A; color:white;text-transform:uppercase; padding-left:25px;"><strong>EQUINE</strong></td>
<?php endif; ?>
</tr>
<tr>
<?php if ($row['homeschool'] == 'Virginia Intermont College - VA'): ?>
<td><p style="text-shadow: none; margin-bottom: -7px;"><strong><?php echo $row['homeschool'];?>vs.</strong><br ><?php echo $row['visitorschool'];?></p></td>
<?php else: ?>
<td><p style="text-shadow: none; margin-bottom: -7px;"><?php echo $row['visitorschool'];?>@<br ><?php echo $row['homeschool'];?></p></td>
<?php endif; ?>
<?php if ($row['homescore'] != ' ' and $row['homeschool'] == 'Virginia Intermont College - VA'): ?>
<td><p style="text-shadow: none; margin-bottom: -7px;"><?php echo $row['homescore'];?><br ><?php echo $row['visitorscore'];?></p></td>
<?php elseif ($row['homescore'] != ' ' and $row['homeschool'] != 'Virginia Intermont College - VA'): ?>
<td><p style="text-shadow: none; margin-bottom: -7px;"><?php echo $row['visitorscore'];?><br ><?php echo $row['homescore'];?></p></td>
<?php elseif ($row['score'] != ' '): ?>
<td><p style="text-shadow: none; margin-bottom: -7px;"><?php echo $row['score'];?></p></td>
<?php elseif ($row['score'] == ' ' and $row['homescore'] == ' '): ?>
<td><p style="text-shadow: none; margin-bottom: -7px;"><?php echo $row['gametime'];?></p></td>
<?php endif; ?>
</tr>
<?php
$day=date('l, F d, Y', strtotime($row['gamedate']));
}
}
?>
</tbody>
</table>
<?php
} else {?>
<span style="vertical-align:top;margin-left:-16px;padding:0;"><img src="images/cobrasschedule.png" border="0"/></span>
<?php
echo "Schedule is not available.";
}
mysql_free_result($result);
?>
我有同样的代码在另一个地方工作,当我在 phpMyAdmin 中运行查询时,它返回 5 行。但是,当我在网站上运行它时,它总是说“计划不可用”。
任何帮助将不胜感激。谢谢!