//Open a recordset of events
$bDone1 = false;
$sSQL1 = "SELECT * FROM tblSchedule WHERE room_num = 1 AND item_date = '".date("Y-m-d",strtotime($StartDate))."' ORDER BY time_from";
$result1 = mysql_query($sSQL1) or die (" ".mysql_error() ."
".$sSQL1);
$array_room1 = mysql_fetch_array( $result1 );
$bDone2 = false;
$sSQL2 = "SELECT * FROM tblSchedule WHERE room_num = 2 AND item_date = '".date("Y-m-d",strtotime($StartDate))."' ORDER BY time_from";
$result2 = mysql_query($sSQL2) or die (" ".mysql_error() ."
".$sSQL2);
$array_room2 = mysql_fetch_array( $result2 );
$bDone3 = false;
$sSQL3 = "SELECT * FROM tblSchedule WHERE room_num = 3 AND item_date = '".date("Y-m-d",strtotime($StartDate))."' ORDER BY time_from";
$result3 = mysql_query($sSQL3) or die (" ".mysql_error() ."
".$sSQL3);
$array_room3 = mysql_fetch_array( $result3 );
$bDone4 = false;
$sSQL4 = "SELECT * FROM tblSchedule WHERE room_num = 4 AND item_date = '".date("Y-m-d",strtotime($StartDate))."' ORDER BY time_from";
$result4 = mysql_query($sSQL4) or die (" ".mysql_error() ."
".$sSQL4);
$array_room4 = mysql_fetch_array( $result4 );
$bDone5 = false;
$sSQL5 = "SELECT * FROM tblSchedule WHERE room_num = 5 AND item_date = '".date("Y-m-d",strtotime($StartDate))."' ORDER BY time_from";
$result5 = mysql_query($sSQL5) or die (" ".mysql_error() ."
".$sSQL5);
$array_room5 = mysql_fetch_array( $result5 );
$bDone6 = false;
$sSQL6 = "SELECT * FROM tblSchedule WHERE room_num = 6 AND item_date = '".date("Y-m-d",strtotime($StartDate))."' ORDER BY time_from";
$result6 = mysql_query($sSQL6) or die (" ".mysql_error() ."
".$sSQL6);
$array_room6 = mysql_fetch_array( $result6 );
$bDone7 = false;
$sSQL7 = "SELECT * FROM tblSchedule WHERE room_num = 7 AND item_date = '".date("Y-m-d",strtotime($StartDate))."' ORDER BY time_from";
$result7 = mysql_query($sSQL7) or die (" ".mysql_error() ."
".$sSQL7);
$array_room7 = mysql_fetch_array( $result7 );
$bDone8 = false;
$sSQL8 = "SELECT * FROM tblSchedule WHERE room_num = 8 AND item_date = '".date("Y-m-d",strtotime($StartDate))."' ORDER BY time_from";
$result8 = mysql_query($sSQL8) or die (" ".mysql_error() ."
".$sSQL8);
$array_room8 = mysql_fetch_array( $result8 );
$bDone10 = false;
$sSQL10 = "SELECT * FROM tblSchedule WHERE room_num = 10 AND item_date = '".date("Y-m-d",strtotime($StartDate))."' ORDER BY time_from";
$result10 = mysql_query($sSQL10) or die (" ".mysql_error() ."
".$sSQL10);
$array_room10 = mysql_fetch_array( $result10 );
$bDone11 = false;
$sSQL11 = "SELECT * FROM tblSchedule WHERE room_num = 11 AND item_date = '".date("Y-m-d",strtotime($StartDate))."' ORDER BY time_from";
$result11 = mysql_query($sSQL11) or die (" ".mysql_error() ."
".$sSQL11);
$array_room11 = mysql_fetch_array( $result11 );
for ($i = mktime(8, 0, 0, date("m",strtotime($StartDate)), date("d",strtotime($StartDate)), date("Y",strtotime($StartDate)));
$i < mktime(21, 30, 0, date("m",strtotime($StartDate)), date("d",strtotime($StartDate)), date("Y",strtotime($StartDate)));
$i = $i + 1800)
{
//echo "i = $i(".date("g:i a", $i)."), from = $array_room1[time_from](".date("g:i a", $array_room1[time_from])."), to = $array_room1[time_to](".date("g:i a", $array_room1[time_to])."), $array_room1[item_desc] ";
//===============================================
//Conf room number 1
$sEvent1 = " ";
if($array_room1[item_id] == "")
{ $bDone1 == true; }
if($bDone1 == false)
{
//Check the first conference room for a scheduled event
if($i >= $array_room1[time_from] && $i <= $array_room1[time_to])
{
//a row was returned
$bgcolor1 = "darkrow";
if($i == $array_room1[time_from])
{
$sEvent1 = "Reserved";
//$sEvent1 = trim($array_room1[item_desc]);
}
if($i + 1800 == $array_room1[time_to])
{ //grab another row
$array_room1 = mysql_fetch_array( $result1 );
}
}
else{
//nothing scheduled, available time slot
$bgcolor1 = "lightrow";
if($i > $array_room1[time_to])
{ //grab another row
$array_room1 = mysql_fetch_array( $result1 );
}
}
}
else { $bgcolor1 = "lightrow"; }
//===============================================
//Conf room number 2
$sEvent2 = " ";
if($array_room2[item_id] == "")
{ $bDone2 == true; }
if($bDone2 == false)
{
//Check the first conference room for a scheduled event
if($i >= $array_room2[time_from] && $i < $array_room2[time_to])
{
//a row was returned
$bgcolor2 = "darkrow";
if($i == $array_room2[time_from])
{
$sEvent2 = "Reserved";
//$sEvent2 = trim($array_room2[item_desc]);
}
if($i == $array_room2[time_to])
{ //grab another row
$array_room2 = mysql_fetch_array( $result2 );
}
}
else{
//nothing scheduled, available time slot
$bgcolor2 = "lightrow";
if($i > $array_room2[time_to])
{ //grab another row
$array_room2 = mysql_fetch_array( $result2 );
}
}
}
else { $bgcolor2 = "lightrow"; }
//===============================================
//Conf room number 3
$sEvent3 = " ";
if($array_room3[item_id] == "")
{ $bDone3 == true; }
if($bDone3 == false)
{
//Check the first conference room for a scheduled event
if($i >= $array_room3[time_from] && $i < $array_room3[time_to])
{
//a row was returned
$bgcolor3 = "darkrow";
if($i == $array_room3[time_from])
{
$sEvent3 = "Reserved";
//$sEvent3 = trim($array_room3[item_desc]);
}
if($i == $array_room3[time_to])
{ //grab another row
$array_room3 = mysql_fetch_array( $result3 );
}
}
else{
//nothing scheduled, available time slot
$bgcolor3 = "lightrow";
if($i > $array_room3[time_to])
{ //grab another row
$array_room3 = mysql_fetch_array( $result3 );
}
}
}
else { $bgcolor3 = "lightrow"; }
//===============================================
//Conf room number 4
$sEvent4 = " ";
if($array_room4[item_id] == "")
{ $bDone4 == true; }
if($bDone4 == false)
{
//Check the first conference room for a scheduled event
if($i >= $array_room4[time_from] && $i < $array_room4[time_to])
{
//a row was returned
$bgcolor4 = "darkrow";
if($i == $array_room4[time_from])
{
$sEvent4 = "Reserved";
//$sEvent4 = trim($array_room4[item_desc]);
}
if($i == $array_room4[time_to])
{ //grab another row
$array_room4 = mysql_fetch_array( $result4 );
}
}
else{
//nothing scheduled, available time slot
$bgcolor4 = "lightrow";
if($i > $array_room4[time_to])
{ //grab another row
$array_room4 = mysql_fetch_array( $result4 );
}
}
}
else { $bgcolor4 = "lightrow"; }
//===============================================
//Conf room number 5
$sEvent5 = " ";
if($array_room5[item_id] == "")
{ $bDone5 == true; }
if($bDone5 == false)
{
//Check the first conference room for a scheduled event
if($i >= $array_room5[time_from] && $i < $array_room5[time_to])
{
//a row was returned
$bgcolor5 = "darkrow";
if($i == $array_room5[time_from])
{
$sEvent5 = "Reserved";
//$sEvent5 = trim($array_room5[item_desc]);
}
if($i == $array_room5[time_to])
{ //grab another row
$array_room5 = mysql_fetch_array( $result5 );
}
}
else{
//nothing scheduled, available time slot
$bgcolor5 = "lightrow";
if($i > $array_room5[time_to])
{ //grab another row
$array_room5 = mysql_fetch_array( $result5 );
}
}
}
else { $bgcolor5 = "lightrow"; }
//===============================================
//Conf room number 6
$sEvent6 = " ";
if($array_room6[item_id] == "")
{ $bDone6 == true; }
if($bDone6 == false)
{
//Check the first conference room for a scheduled event
if($i >= $array_room6[time_from] && $i < $array_room6[time_to])
{
//a row was returned
$bgcolor6 = "darkrow";
if($i == $array_room6[time_from])
{
$sEvent6 = "Reserved";
//$sEvent6 = trim($array_room6[item_desc]);
}
if($i == $array_room6[time_to])
{ //grab another row
$array_room6 = mysql_fetch_array( $result6 );
}
}
else{
//nothing scheduled, available time slot
$bgcolor6 = "lightrow";
if($i > $array_room6[time_to])
{ //grab another row
$array_room6 = mysql_fetch_array( $result6 );
}
}
}
else { $bgcolor6 = "lightrow"; }
//===============================================
//Conf room number 7
$sEvent7 = " ";
if($array_room7[item_id] == "")
{ $bDone7 == true; }
if($bDone7 == false)
{
//Check the first conference room for a scheduled event
if($i >= $array_room7[time_from] && $i < $array_room7[time_to])
{
//a row was returned
$bgcolor7 = "darkrow";
if($i == $array_room7[time_from])
{
$sEvent7 = "Reserved";
//$sEvent7 = trim($array_room7[item_desc]);
}
if($i == $array_room7[time_to])
{ //grab another row
$array_room7 = mysql_fetch_array( $result7 );
}
}
else{
//nothing scheduled, available time slot
$bgcolor7 = "lightrow";
if($i > $array_room7[time_to])
{ //grab another row
$array_room7 = mysql_fetch_array( $result7 );
}
}
}
else { $bgcolor7 = "lightrow"; }
//===============================================
//Conf room number 8
$sEvent8 = " ";
if($array_room8[item_id] == "")
{ $bDone8 == true; }
if($bDone8 == false)
{
//Check the first conference room for a scheduled event
if($i >= $array_room8[time_from] && $i < $array_room8[time_to])
{
//a row was returned
$bgcolor8 = "darkrow";
if($i == $array_room8[time_from])
{
$sEvent8 = "Reserved";
//$sEvent8 = trim($array_room8[item_desc]);
}
if($i == $array_room8[time_to])
{ //grab another row
$array_room8 = mysql_fetch_array( $result8 );
}
}
else{
//nothing scheduled, available time slot
$bgcolor8 = "lightrow";
if($i > $array_room8[time_to])
{ //grab another row
$array_room8 = mysql_fetch_array( $result8 );
}
}
}
else { $bgcolor8 = "lightrow"; }
//===============================================
//Conf room number 10
$sEvent10 = " ";
if($array_room10[item_id] == "")
{ $bDone10 == true; }
if($bDone10 == false)
{
//Check the first conference room for a scheduled event
if($i >= $array_room10[time_from] && $i < $array_room10[time_to])
{
//a row was returned
$bgcolor10 = "darkrow";
if($i == $array_room10[time_from])
{
$sEvent10 = "Reserved";
//$sEvent10 = trim($array_room10[item_desc]);
}
if($i == $array_room10[time_to])
{ //grab another row
$array_room10 = mysql_fetch_array( $result10 );
}
}
else{
//nothing scheduled, available time slot
$bgcolor10 = "lightrow";
if($i > $array_room10[time_to])
{ //grab another row
$array_room10 = mysql_fetch_array( $result10 );
}
}
}
else { $bgcolor10 = "lightrow"; }
//===============================================
//Conf room number 11
$sEvent11 = " ";
if($array_room11[item_id] == "")
{ $bDone11 == true; }
if($bDone11 == false)
{
//Check the first conference room for a scheduled event
if($i >= $array_room11[time_from] && $i < $array_room11[time_to])
{
//a row was returned
$bgcolor11 = "darkrow";
if($i == $array_room11[time_from])
{
$sEvent11 = "Reserved";
}
if($i == $array_room11[time_to])
{ //grab another row
$array_room11 = mysql_fetch_array( $result11 );
}
}
else{
//nothing scheduled, available time slot
$bgcolor11 = "lightrow";
if($i > $array_room11[time_to])
{ //grab another row
$array_room11 = mysql_fetch_array( $result11 );
}
}
}
else { $bgcolor11 = "lightrow"; }
//Print the row
echo "
| ".date("g:i a", $i)." |
$sEvent1 |
$sEvent2 |
$sEvent3 |
$sEvent4 |
$sEvent5 |
$sEvent6 |
$sEvent7 |
$sEvent8 |
$sEvent10 |
$sEvent11 |
";
}
?>
|