Page 1 of 1

getting dates from 2 booking tables to display as booked

Posted: Tue Dec 23, 2003 4:59 am
by ruud
Hi there

i'm fairly new to php so be gentle

I am doing a booking sytem for a motorhome company that has two motorhomes. I have 2 tables in my db (one for each motorhome) that record the dates booked by the user. The user can view a calendar that shows when dates are booked. However this only works currently by querying one of the booking tables. I would like to update the calendar so it queries both tables. So say if january is completely booked up in the book1 table yet is completely free on book2 then i still want the calendar to show the dates as free.

Currently i 'm playing around with the idea of two sql queries that select dates from book1 and dates from book2 and then give the results in an array. Then i'm using an if statement that says if book1 dates match up with book2 dates then show as booked on the calendar. Obviously this is not working at the moment but i just need someone to say whether i'm on the right lines or just heading up a deep dark dead end. Thanks in advance for any help. :)

Posted: Tue Dec 23, 2003 5:27 am
by twigletmac
The imediate problem is that you have two tables instead of one. Instead of separate tables for each motorhome it would be easier to maintain one with a new field to store which motorhome is having dates added to it. That way when you display the calendar you only need a simple query on one table and you can easily get all the dates for a specific motorhome by doing a select using its ID.

Mac

Posted: Tue Dec 23, 2003 7:13 am
by ruud
thanks for replying mac. Great help :)