grayfoxmy
04-18-2011, 08:59 PM
I have this problem for the looping which repeating the schedule time multiple times as because of the loop. Here is the script..and is high lighted part is the bug i problem encounter. Thank You:D
<html>
<body>
<form>
<?
function ConvertDate($sql_date)
{
$date=strtotime($sql_date);
$final_date=date("Y-m-d", $date);
return $final_date;}
function ConvertTime($sql_date)
{
$date=strtotime($sql_date);
$final_date=date("g:i a", $date);
return $final_date;
}
$timeStrt='9:00';
//3 bookers testing data!
for($i=0;$i<3;$i++)
{
$name[$i]="mr $i";
}
$time[0]="10:00 am";
$time[1]="11:15 am";
$time[2]="10:00 am";
$room[0]=1;
$room[1]=0;
$room[2]=1;
//testing data ends here
echo "<table border=1><tr>";
//simulation 2 rooms
for($j=0;$j<2;$j++)
{
echo "<td><table border=1>";
echo "<tr><td> ROOM: $j</td></tr>";
echo"
<tr><td>Time</td><td>Book</td></tr>
";
for($k=0;$k<=28800;$k=$k+900)//8hours and 15min apart
{
//these 3 persons is the main problem for resulting the time repeating! BUG
for($i=0;$i<3;$i++)
if(ConvertTime(date('H:i', strtotime($timeStrt) +$k)) == $time[$i] && $room[$i]==$j)
//if time of the display time = to book time and booked room = to room then show
{
echo "<tr><td>".ConvertTime(date('H:i', strtotime($timeStrt) +$k))."+".$name[$i]."</td>
<td>Yes</td></tr>";
}
else//show time and the place is empty for radio button to select
{
echo "<tr><td>".ConvertTime(date('H:i', strtotime($timeStrt) +$k))."</td><td><input type='radio' name='RadioGroup' value='$j ".ConvertTime(date('H:i', strtotime($timeStrt) +$k))."'></td></tr>";
}
}
echo "</td></table>";
}
echo"</td></tr></table>";
?>
</form>
</body>
</html>
<html>
<body>
<form>
<?
function ConvertDate($sql_date)
{
$date=strtotime($sql_date);
$final_date=date("Y-m-d", $date);
return $final_date;}
function ConvertTime($sql_date)
{
$date=strtotime($sql_date);
$final_date=date("g:i a", $date);
return $final_date;
}
$timeStrt='9:00';
//3 bookers testing data!
for($i=0;$i<3;$i++)
{
$name[$i]="mr $i";
}
$time[0]="10:00 am";
$time[1]="11:15 am";
$time[2]="10:00 am";
$room[0]=1;
$room[1]=0;
$room[2]=1;
//testing data ends here
echo "<table border=1><tr>";
//simulation 2 rooms
for($j=0;$j<2;$j++)
{
echo "<td><table border=1>";
echo "<tr><td> ROOM: $j</td></tr>";
echo"
<tr><td>Time</td><td>Book</td></tr>
";
for($k=0;$k<=28800;$k=$k+900)//8hours and 15min apart
{
//these 3 persons is the main problem for resulting the time repeating! BUG
for($i=0;$i<3;$i++)
if(ConvertTime(date('H:i', strtotime($timeStrt) +$k)) == $time[$i] && $room[$i]==$j)
//if time of the display time = to book time and booked room = to room then show
{
echo "<tr><td>".ConvertTime(date('H:i', strtotime($timeStrt) +$k))."+".$name[$i]."</td>
<td>Yes</td></tr>";
}
else//show time and the place is empty for radio button to select
{
echo "<tr><td>".ConvertTime(date('H:i', strtotime($timeStrt) +$k))."</td><td><input type='radio' name='RadioGroup' value='$j ".ConvertTime(date('H:i', strtotime($timeStrt) +$k))."'></td></tr>";
}
}
echo "</td></table>";
}
echo"</td></tr></table>";
?>
</form>
</body>
</html>