我正在制作一个日历系统,用户可以在其中进行预订(在不同的页面上)。在此页面上,用户单击相关框以选择新预订的开始时间。我正在检查现有预订的数据库,并使这些预订不可点击以防止重复预订。
我的问题是,为什么只有当天的第一个预订出现在桌子上?
变量是否$booked
保持真实,因此不显示其他预订?我无法理解它!
MySQL:
$query="SELECT * FROM bookings WHERE DateBooked = '{$year}-{$month}-{$selectedday}' AND Approved = 1";
$result = mysql_query($query);
$todayarray = mysql_fetch_assoc($result);
和 PHP:
while ($room <= $roomcount) {
echo "\n<div class=\"roomtimes\">";
echo "\n<table border=1>";
echo "\n<tr><th class=\"titlecell\">Room $room</th></tr>";
$cellnum = 10;
while ($cellnum <= 22) {
if (($todayarray['StartTime'] <= $cellnum) && ($todayarray['EndTime'] >= $cellnum) && ($todayarray['Room'] == $room)) {
$booked = true;
} else {
$booked = false;
}
echo "\n<tr>";
if ($booked) {
echo "\n<td class=\"blankcell";
} else {
echo "\n<td class=\"linkcell";
}
if ($selectedtime == $cellnum) {
echo " selectedcell";
}
echo "\">";
if ($booked) {
echo "$cellnum:00 --BOOKED--";
} else {
echo "<a href=\"newbooking.php?m=$selectedmonth&d=$selectedday&t=$cellnum&r=$room\">$cellnum:00</a>";
}
echo "</td>";
echo "\n</tr>";
$cellnum++;
}
$room++;
echo "\n</table>";
echo "\n</div>";
}
echo "\n</div>";
?>