저는 주 단위로 (24 시간짜리) 일주일 단위로 일을하고 있습니다. 이것은 몇 시간 동안 예약했는지 그리고 어떤 요일에 기록했는지 기록하는 데 사용됩니다.PHP 캘린더 표시 여러개
예약 할 때 시간표가있는 것과 같습니다. 예약 된 슬롯과 예약되지 않은 슬롯이 다른지 확인하기 위해 PHP if 문을 사용하여 데이터베이스와 시간을 비교했습니다.
문제입니다; 나는 if 문이 여러 행에 걸쳐 작동하는 while 문과 달리 한 행에서만 작동한다고 믿습니다. -
- 그리고
(달력에 표시하는 것은 데이터베이스 삽입 문제가되지 않습니다) 하루에 한 시간 이상을 볼 - 그래서 기본적으로 나는 하루에 한 시간 이상을 예약 할 수 있도록하려면 나는 내 일정/일정을 어떻게 구성할지는 모르겠다. (I 9 월 9 일 18:00 예약하는 경우 - 그것은 표시되지 것)http://postimage.org/image/gcb3x3fk3/
$ globalid 글로벌 변수 및 파일/코드 내에서 보관 유지되어 있지 않은 : 여기
은 내 문제입니다 아래 ..
MY 코드
<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>
그렇다. 그러나 하루에 두 개 이상의 예약 된 슬롯을 표시하는 문제가 해결되지 않습니다. – Andrew
문제를 올바르게 이해하지 못합니다. 그것에 대해 더 많이 말해 줄 수 있니? – StasGrin
예약 된 슬롯을 하루에 두 개 이상 표시하려고합니다. 현재 if 문은 그 날에 예약 된 모든 시간을 표시하지만 현재 추가 할 수없는 현재 코드가있는 while 문과 달리 첫 번째 행/시간 (그 날의 경우 - 삽입의 ID/시간순으로) 만 알려줍니다. while 문이 내 코드 둘레에 있다고 생각하지 않습니다. – Andrew