Jump to content

How to implement check availability in hotel reservation system


jyotiu

Recommended Posts

Hi ppl

 

I am developing website for my friend's very small resort, please see www.shivgangaresorts.com/dev

 

this resort have 8 rooms in total and all rooms are of same type so every room is equally priced.

 

I just need code or logic to check availability of given no. of rooms on given check in and check out dates.

 

when somebody makes a reservation, details that go in reservation table is:

booking_id

customer name

email

check-in date

check-out date

no. of rooms

 

Please help this is very critical as i will be integrating paypal also, so there should be no confusions...

 

thanks in advance

Link to comment
Share on other sites

Assuming your database looks like:

 

rooms (rooms_id, rooms_beds, rooms_price, ..)

customers (customers_id, customers_name, ..)

 

bookings (bookings_id, bookings_customers_id, bookings_rooms_id, bookings_reservation_date, bookings_check_in, bookings_check_out, ..)

 

Then the code would be something similar like:

 

SELECT count(*) as available_rooms
FROM rooms
WHERE rooms_id NOT IN (
    # select all rooms wich are currently in use or will be used soon
    SELECT bookings_rooms_id
    FROM bookings
    WHERE (bookings_reservation_date > NOW() AND bookings_reservation_date < NOW() + 14) # room reservation within 14 days (adjust if needed)
    OR bookings_check_out IS NULL # a customer is already using the room and has not yet checked_out
);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.