Hi,
I am developing a hotel reservation system using PHP and MySQL. The query to check availability is causing problems: I have a reservation, room, rates and customer table.
Room contains room type and room no. Reservation contains cust id, room no, date from, date to etc..
The customer enters room type ($type), date from ($arrival_date) and date to, and availability is checked in the reservation table. I am using the following query:
SELECT room.room_no, reservation.reservation_id FROM room LEFT JOIN reservation ON room.room_no = reservation.room_no WHERE $arrival_date NOT BETWEEN reservation.arrival_date AND reservation.dept_date AND room.type = '$type'
If a room is available on the arrival night, I then check the number of nights they want to stay, and loop through the query for each night, to see if the room is still available.
If so the reservation is made.
But the query is returning unexpected results sometimes. I have tried many variations, but to no use. Please help in any way.