I'm working on this online reservation project and I am stock in this part. Here's the scenario. database structure:
tbl_guestinfo
guest_id
name
checkin
checkout
numAdults
numChild
tbl_rooms
room_id
room_name
guest_id
type_id
tbl_roomtype
type_id
room_rate
room_type
noOf_Rooms
I can already get a good result from my query wherein I could scan all available rooms and display all my the information that I want.
SELECT *
FROM tbl_rooms, tbl_roomtype
WHERE guest_id NOT IN
(
SELECT `guest_id` from tbl_guestinfo where
(`checkin` < ' $varCheckOut' and `checkout`>= '$varCheckOut' )
OR (`checkin`<= '$varCheckIn' and `checkout`> '$varCheckIn' )
OR (`checkin`>= '$varCheckIn' and `checkout`<='$varCheckOut')
)
What I need is to display all the remaining room_type that is available. So for example if there are 5 standard room and 5 deluxe room and 1 standard room is occupied by guest1 from 2012-10-01 to 2012-10-05 and 1 deluxe room occupied at the same date by guest2 then the site will be still displaying standard and deluxe room since there are 4 left for each of the room_type.
Note that I will be putting the room_type in a html table and noOf_Rooms left in a combo box.
Please help been researching and reading a lot but still can't figure it out. Thank you in advance for all your help.
Cheers