i need to make a php code for checking hotel room avaibility where user from the present day can book rooms upto 90 days or less and there are total 30 rooms available in the hotel,so if once i store the data for a user like his booking from one date till another next time if i want to check the avaibility how should i do it in php,what would be the logic.
obviously i simple query like this isn’t correct
for eg
$this->db->select('*')
->from('default_bookings')
->where('booking_from <',$input['fromdate'])
->where('booking_till >',$input['tilldate']);
I assume, you want to find free space in you booking-calendar.
So you have a start-date and an end-date. You look in every room and make the following assumptions:
A SQL-Query could look like this:
Is the result is 0, then there is no intersection with existing reservations.
You can also automate the “looking into rooms” by using this query as a sub-query.