Hi newbie here
I’m currently making a hotel booking system in mysql/php, but I’m having problems with overlapping dates/double bookings.
For example if a user attempted to book room1 from the 1st august to the 5th august, but the room is already booked on the 3rd and unavailable on the 5th it would book the 1st,2nd, & 4th . I would like it to check the availability of other rooms available during the chosen period if the dates cannot be entirely fulfilled. For example Room 2 is free on the 3rd so the user is offered this alternative.
Below is the table data. If the status is ‘2’ then the room is booked a status of ‘1’ means the room is available and a status of ‘3’ means the room is unavailable.
Caldate, RoomID, status, BookingID
2010-08-01, 1, 1 Null
2010-08-02, 1, 1, Null
2010-08-03, 1, 2, Null
2010-08-04, 1, 1, Null
2010-08-05, 1, 3, Null
2010-08-01, 2, 2, Null
2010-08-02, 2, 2, Null
2010-08-03, 2, 1, Null
2010-08-04, 2, 2, Null
2010-08-05, 2, 1, Null
My current update query is:
UPDATE calendar
SET status=’2’, BookingID=’’
WHERE RoomID=’1’
AND status =’1’
AND caldate BETWEEN ‘2010-08-01’ AND ‘2010-08-05’
Any help would be appreciated. Thanks
Booking System - How to deal with double bookings
Moderator: General Moderators
Re: Booking System - How to deal with double bookings
If I was a hotel customer, and I wanted from the 1st to the 5th, I'd want it in one room only. I wouldn't be interested in moving to a different room for one night, then moving back. I'd just go to a different hotel.
In booking software I've written, it's all or nothing. Either a resource is available for the entire time the user requests it, or it's not available at all.
In booking software I've written, it's all or nothing. Either a resource is available for the entire time the user requests it, or it's not available at all.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: Booking System - How to deal with double bookings
I agree with you pickle but its something that my client would like me to attempt.