Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am developing website for my friend's very small resort, please see www.shivgangaresorts.com/dev
This resort has 8 rooms in total and all rooms are of the 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 are:
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...
If all rooms are available for 24 hours a day, 7 days a week then your reservation should have a start_time (timestamp) and end_time (timestamp) rather than just the date.
A standard reservation likely has a specific start time (~6pm) and ending (~11am) but you may want to be specific in order to offer early arrivals or late checkouts.
This is the logic I'd user:
User picks check-in date and check-out date.
Your program grabs 6pm of check in date and 11am of checkout date and selects the rooms are not booked within those times based on the current reservations. (return rooms)
This sounds like a fairly simple approach but you may need to account for maid times, splitting up the reservation between rooms, rooms on hold, etc.
I guess if you're checking the availability on every page refresh, I'd compute how many free rooms by grabbing how many bookings are in effect at the current time:
select sum(number_of_rooms) from reservations where
check_in_date <= now() and
check_out_date >= now()
This will give you your current rooms that are occupied. Then simply subtract this value from a hard-coded 'room total' value.
It might help to normalize the database by having a customer and individual room table with a linking table to the booking table. However I am unaware of your contraints.
You need a procedure to determine how many rooms are available. The simplest answer for a small number of rooms would be to loop through each room and check availability during the period. That is, if a booking exists for a given room during the period, it's not available.
If you want to consider splitting a booking between rooms, it becomes more difficult, but you should then check availability for each room for each day during the period, then aggregating the results.
Related
I am currently trying to build a reservation system for a tennis club.
The original idea was that people are paying for a subscription and play always on the same time/day in the week.
That would be fairly easy for me, but I've got told that there has to be a way to rearrange specific reservations if there's like a tournament on that day.
So i'm not familiar with MySQL(i), but I know that you can't just have an array for all the dates and add dates to it, right?
In my plan i'd have a "Customer" with Name, adress etc. and with the booked dates. How can I now have any amount of dates which I can delete, change or create with MySQL(i)?
I'm working on a reservation/booking system for a small hotel. I'm pretty good with PHP but not so good with SQL... I made a form where you enter your information, number of rooms and select arrival date and check-out date using a calendar.
Now everything went good until I got to the point where you have to check which rooms are available and it's giving me a headache. There are 10 rooms you can book.
I currently have one table in MySQL storing the information, dates, booking-ID and room-ID/number.
How would you make the SQL for checking which rooms that are available and not?
Should it look something like
"SELECT * FROM bookings WHERE checkinDate >= '$formCheckin'
AND checkoutDate <= '$formCheckout' "
and then get the roomID and count them?
Any help is very appreciated!
If you want to know if a room is available during a period, then the logic looks like:
SELECT r.*
FROM rooms r
WHERE NOT EXISTS (SELECT 1
FROM bookings b
WHERE b.roomid = r.roomid AND
b.checkinDate <= $formCheckOut AND
b.checkoutDate >= '$formCheckIn
);
I'm not sure if the equality comparison is needed for both of these. The logic is that a room is available if there are no bookings that start before the checkout date and that end after the check in date.
However, for ten rooms, I might suggest that you just keep a table of each room by day, say for the next ten years (add another year once per year). Such a table isn't very big and it is probably easier to understand how to use it. Plus, you can handle things like a couple reserve the room for a week, but only one person is in the room for the first 3 days.
I'm very new in this site. Spend a lot of time for searching an answer for my target, but unsuccessfully. So, there it is (sorry for my english):
I'm quite new in php, but already created nice stuff. But now I'm interested in calendar with time slot reservation. I saw good exemple then I registered for my doctor. There i was able to choose a day from calendar and then select a free time range (e.g. from 12:00 to 12:30).
First idea for this is some calendar in PHP and table in MySQL. In MySQL table few rows with id, name and quantity. id - unique number of row, name - date and time slot, and quantity - (1 = free cell, 0 = unable). In PHP calendar after selecting a free time slot, in DB quantity goes from 1 to 0 and apear unavailable for other users.
But if where are a lots of "doctors"? How to make calendar, DB for thousands of them?
For the beggining maybie someone have some example how to make calendar with time reservation (e.g. 1 hour) in the easiest way? Or suggest something?
We are trying to design a program that will allow users to book tutors based on tutors' availability. So we want tutors to tell us when (what time, day, etc) they are available/not available, and when a user books a specific day and time, we only want to show that user the tutors that are available for that particular day and time.
For example, tutors could tell us they are available M-W from 9-5PM.
How could I design such a table?
I was thinking of doing the followin
non-availability:
(this allows tutors to tell me they are not available on a specific date ... say 4/15/2012 10PM)
date date
time_start datetime
time_end datetime
recurring_non-availability
(this allows tutors to tell me that they are not available every Monday from 9-5pm)
dayOfWeek enum
time_start
time_end
So basically, tutors can specify for each day of the week, the times they are not available. They can also specify specific dates they are not available. If a user wants a tutor for a specific date like 4/20 10AM, I will first query the non-availability table to make sure there are no conflicts for 4/20 10 AM, and then query the recurring_non_availability table to make sure they are no conflicts for Friday (4/20 is on a Friday) 10 AM. I am not sure if this design will give me the best picture of a tutor's availability.
Perhaps set up a table with all the days of the week tutors will be available and then have the times they are stored within like so?
Tutor monday tuesday wednesday thursday friday
bob 9-5 9-5 9-5 10-3 9-12
I have a online course having 50 lessons.
Now what i want to achieve is that each lesson is shown 1 day at a time or every 24 hours depending on the date the members are subscribed?
Note:- members Can subscribed at different dates and times.
Any idea how can i achive that?
I am not sure this is a scheduled task, but more of a bit of logic in your php code that doesn't show the link for courses that are not accessible yet.
This should be fairly simple date processing based on a users registration date.
Here is a post on stack overflow for calculating date differences.
PHP date calculation