Big problem with booking system PHP + SQL -


I am now making a new booking system, part of the private room and now I am a part of the dorm.

The system works like this:

  1. Skip to Day + Day + How many people in the hostel

  2. The system checks DB (by the way MESQL) if the free room is now how does it check? There is a number of dates in DB - a date person. For example, we have a hostel with dates: 05/08, 05/08, 05/08, 05/08, 06/08, 06/08, 06/08, 06/08, 07/08, 07 / 08, 07/08, 07/08 - Therefore Dorm 05/07/08 has 4 people. For example, if this room is 4 out of 10 with 10 people. Now if you include 7 people you do not have. (This will be 11 out of 10)

  3. The system returns the available rooms.

Now I want to talk further: if there is 2 hostels. All of them have space for 10 people, all of them 10 out of 10 people. Now 4 people are coming and they want to register. Do not give them this because they check the dorm-dorm. I want to do this that the system will calculate free places (10-8 + 10-8 = 4 in 2 dorms)

Edit:

P> When I add hostel to the database:

  id Room_type | Individuals | Date ------------------------------------------------- ----------------------- X | Hostel How many people are in the hostel?  

If you have 5 dates then = 5 people in the hostel at this date, for example.

OK, so I'm typing it from memory so it needs some fine-tuning But it should work as a guide. Hope this will be helpful.

1) First of all, let's create a floating table that stores all the ocupidated slots for each minute in any room:

  make temporary table cell_available SELECTION ID, DISTINCT DATES, COUNT (dated) to complete_slot table as WHERE UNIX_TIMESTAMP (CAST (date)) - UNIX_TIMESTAMP (now ()) 0 groups according to date by ID;  

2) Obtain all available slots for any room:

  SELECT table. *, Table.persons - as room_availability.full_slots in the free_slots table in INNER table_id = room_availability.id where tables are available in the table, where the table .persons - room_availability.full_slots & gt; 3) Finally, get rid of the temporary table and you have done 

PS: Unix timestamp is to help you in the list of future dates.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -