我正在做一个每周(24 小时日历),这将用于记录已预订的时间和日期。
这就像您预订的带有插槽的时间表。为了确保已预订和未预订的时段不同,我在 PHP 中放入了 if 语句来检查数据库的时间。
问题是;我相信我的 if 语句只适用于一行,而不是适用于多个的 while 语句。- 所以基本上我希望能够每天预订超过一小时 - 并且每天看到超过一小时
(数据库插入不是问题 - 在日历上显示它是)
我不能做一个while语句,因为我不确定如何用一个来构建我的日程安排/日历。
这是我的问题: http: //postimage.org/image/gcb3x3fk3/ (如果我在 9 月 9 日预订 18:00 - 它不会显示)
$globalid 是一个全局变量,不包含在下面的文件/代码中(但包含在内)
我的代码
<div id="calendar">
<?
if(isset($_POST['add_week'])){
$week = date('d-m-Y', strtotime($_POST['last_week']));
$new_week = strtotime ( '+1 week' , strtotime ( $week ) ) ;
$new_week = date('d-m-Y', $new_week);
$week_number = date("W", strtotime( $new_week));
$year = date("Y", strtotime( $new_week));
}else if(isset($_POST['back_week'])){
$week = date('d-m-Y', strtotime($_POST['last_week']));
$new_week = strtotime ( '-1 week' , strtotime ( $week ) ) ;
$new_week = date('d-m-Y', $new_week);
$week_number = date("W", strtotime( $new_week));
$year = date("Y", strtotime( $new_week));
}else{
$week_number = date("W");
$year = date("Y");
}
/*if($week_number < 10){
$week_number = "0".$week_number;
}*/
$week_start = date('d-m-Y', strtotime($year."W".$week_number,0));
?>
<table name="week" width="100%" cellspacing="0" cellpadding="0" height="13">
<tr>
<?
for($day=1; $day<=7; $day++)
{
?>
<tr>
<td class="day">
<?
$daycal = date('d M', strtotime($year."W".$week_number.$day))."";
echo $daycal;
?>
</td>
<td width="3"> </td>
<td>
<!-- Timetable -->
<table width="100%" cellspacing="0" cellpadding="0" height="13">
<tr><td>
<?
// Do not edit Below
$cal = mysql_query("SELECT * FROM `calendar` WHERE `day`='$daycal' && `userid`='$globalid'")or die(mysql_error());
$calendar = mysql_fetch_array($cal);
?>
<div class="hour" name="00:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="00:00"){
?>
Booked
<? }else{ ?>
00:00
<? } ?>
</div>
<div class="hour" name="01:00" id="<? echo $daycal; ?>">
<?
if($calendar2['time']=="01:00"){
?>
Booked
<? }else{ ?>
01:00
<? } ?>
</div>
<div class="hour" name="02:00" id="<? echo $daycal; ?>">
<?
if($calendar3['time']=="02:00"){
?>
Booked
<? }else{ ?>
02:00
<? } ?>
</div>
<div class="hour" name="03:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="03:00"){
?>
Booked
<? }else{ ?>
03:00
<? } ?>
</div>
<div class="hour" name="04:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="04:00"){
?>
Booked
<? }else{ ?>
04:00
<? } ?>
</div>
<div class="hour" name="05:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="05:00"){
?>
Booked
<? }else{ ?>
05:00
<? } ?>
</div>
<div class="hour" name="06:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="06:00"){
?>
Booked
<? }else{ ?>
06:00
<? } ?>
</div>
<div class="hour" name="07:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="07:00"){
?>
Booked
<? }else{ ?>
07:00
<? } ?>
</div>
<div class="hour" name="08:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="08:00"){
?>
Booked
<? }else{ ?>
08:00
<? } ?>
</div>
<div class="hour" name="09:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="09:00"){
?>
Booked
<? }else{ ?>
09:00
<? } ?>
</div>
<div class="hour" name="10:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="10:00"){
?>
Booked
<? }else{ ?>
10:00
<? } ?>
</div>
<div class="hour" name="11:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="11:00"){
?>
Booked
<? }else{ ?>
11:00
<? } ?>
</div>
<div class="hour" name="12:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="12:00"){
?>
Booked
<? }else{ ?>
12:00
<? } ?>
</div>
<div class="hour" name="13:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="13:00"){
?>
Booked
<? }else{ ?>
13:00
<? } ?>
</div>
<div class="hour" name="14:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="14:00"){
?>
Booked
<? }else{ ?>
14:00
<? } ?>
</div>
<div class="hour" name="15:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="15:00"){
?>
Booked
<? }else{ ?>
15:00
<? } ?>
</div>
<div class="hour" name="16:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="16:00"){
?>
Booked
<? }else{ ?>
16:00
<? } ?>
</div>
<div class="hour" name="17:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="17:00"){
?>
Booked
<? }else{ ?>
17:00
<? } ?>
</div>
<div class="hour" name="18:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="18:00"){
?>
Booked
<? }else{ ?>
18:00
<? } ?>
</div>
<div class="hour" name="19:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="19:00"){
?>
Booked
<? }else{ ?>
19:00
<? } ?>
</div>
<div class="hour" name="20:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="20:00"){
?>
Booked
<? }else{ ?>
20:00
<? } ?>
</div>
<div class="hour" name="21:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="21:00"){
?>
Booked
<? }else{ ?>
21:00
<? } ?>
</div>
<div class="hour" name="22:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="22:00"){
?>
Booked
<? }else{ ?>
22:00
<? } ?>
</div>
<div class="hour" name="23:00" id="<? echo $daycal; ?>">
<?
if($calendar['time']=="23:00"){
?>
Booked
<? }else{ ?>
23:00
<? } ?>
</div>
</td></tr>
</table>
<!-- End Timetable -->
</td>
</tr>
<tr height="3"><td> </td></tr>
<?
}
?>
</tr>
<tr>
<form name="move_weeks" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="last_week" value="<? echo $week_start; ?>" />
<td colspan="7"><input type="submit" name="back_week" value="back_week" /><input type="submit" name="add_week" value="add_week" />
</td>
</form>
</tr>
</table>
</div>