Room booking time table
Hi all,
I'm trying to create a room booking timetable in PHP that will display booked space simply with a shaded colour in a table cell.
The layout of the table includes relevant times (between 9:00am - 10:00pm) horizontally across the top of the table. Down the left hand side is each room. It is important that I keep this layout.
I have previously managed to grab the data per room and span in over x amount of columns depending on the difference between start_time and end_time.
I can show you what I've got at the minute but it's not working as I've been tinkering etc. If I make an update I'll be sure to post it. I've only included the table rows that will be shaded..
<?php
$q=mysql_query("SELECT id, room_name FROM rooms");
while($rooms=mysql_fetch_object($q))
{
echo "<tr>\n";
echo "<td bgcolor=\"#FFFFFF\"><strong>$rooms->room_name</strong></td>\n";
for ($i=0; $i<=$duration; $i++)
{
$bq=mysql_query("SELECT * FROM bookings, user_groups WHERE (bookings.room_id=$rooms->id AND bookings.date='$shortdate' AND bookings.start_time='$this_hour:00' AND bookings.user_group_id=user_groups.id)");
$booking_details=mysql_fetch_object($bq);
if (mysql_num_rows($bq) == 1)
{
echo "<td bgcolor=\"#C0C0C0\">$booking_details->group_name</td>\n";
}
else
{
echo "<td bgcolor=\"#FFFFFF\"> </td>\n";
}
$this_hour=$this_hour+1;
}
echo "</tr>\n";
$this_hour=substr($times->start_time,0,2);
}
?>
decibel.places posted this at 22:57 — 4th February 2009.
He has: 1,494 posts
Joined: Jun 2008
maybe you can glean something from the Drupal reservation modules
http://drupal.org/project/reservation
http://drupal.org/project/airplane_reservation
pr0gr4mm3r posted this at 02:05 — 5th February 2009.
He has: 1,502 posts
Joined: Sep 2006
So...what's the problem? Can you post a link to your page yet?
a_gajic posted this at 12:24 — 5th February 2009.
They have: 71 posts
Joined: Aug 2001
The problem is that I can't fill in the shaded cells properly. Sorry, I should have said that when it spans over x amount of columns it actually added new columns rather than sitting under the relevant times.
I'll be able to upload it somewhere this evening if you'd like to take a look.
Thanks.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.