Jump to content

hotel booking site


chrispos

Recommended Posts

I am using MySQL 5

 

Good day to you all. I have developed an online booking system for small hotels and  but I would like to take this one step further by selection only hotels that have rooms available in a selected area. The code below selects only available rooms from the database.

"SELECT * FROM rooms WHERE (hid = '$hid') AND rid NOT IN (SELECT rid FROM bookings WHERE (hid = '$hid') AND ((startdate >= ".$start->getTime()." OR enddate > ".$start->getTime().") AND (startdate < ".$end->getTime().")))";

 

the tables are rooms for each individual room, rid for individual room id, hid for the hotels individual id, name for the hotels individual name, address for the address and town where the hotel is located. a separate table for bookings holding start dates and departure dates and room id and hotel id. The get time is a bit of php script called date class. So what I am trying to do is amend this script so that only the individual hotels with available rooms appear in the query.

 

I hope this does not sound to complicated as my head is about to explode doing this.

 

Many thanks for looking and have a great day.

Link to comment
Share on other sites

I am using MySQL 5

 

Good day to you all. I have developed an online booking system for small hotels and  but I would like to take this one step further by selection only hotels that have rooms available in a selected area. The code below selects only available rooms from the database.

"SELECT * FROM rooms WHERE (hid = '$hid') AND rid NOT IN (SELECT rid FROM bookings WHERE (hid = '$hid') AND ((startdate >= ".$start->getTime()." OR enddate > ".$start->getTime().") AND (startdate < ".$end->getTime().")))";

 

the tables are rooms for each individual room, rid for individual room id, hid for the hotels individual id, name for the hotels individual name, address for the address and town where the hotel is located. a separate table for bookings holding start dates and departure dates and room id and hotel id. The get time is a bit of php script called date class. So what I am trying to do is amend this script so that only the individual hotels with available rooms appear in the query.

 

I hope this does not sound to complicated as my head is about to explode doing this.

 

Many thanks for looking and have a great day.

I think I may be making this more complicated.

 

I would like to use the above script but add a query at the start.

"SELECT * FROM hotels WHERE (town = '$town') rooms WHERE (hid = '$hid') AND rid NOT IN (SELECT rid FROM bookings WHERE (hid = '$hid') AND ((startdate >= ".$start->getTime()." OR enddate > ".$start->getTime().") AND (startdate < ".$end->getTime().")))";

 

Do you think this will work

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.