> The one thing I cannot get into my head is how can you tell the database
> that all the days between the "start" and "end" dates are booked.
> Also when
> people search for a caravan on a specific date and say they want it for 7
> day the database/PHP checks to see if the entire period is
> totally free for
> them and does not colide with another booking.
Ray, it looks like you've done some great work so far. This one point that
you are struggling with may not be as difficult as you are imagining as
When a potential customer is searching for availability, they are going to
have to select a start date and an end date for the period they are looking
Then, you just take those two dates, and compare them against the previous
bookings for the same villa... (if you do it in one step, you can tell them
"those dates are not available" - if you perform it in two steps, you can
give the customer more information about whether the start date, or the end
date (or both) were the source of the conflict. ) i.e. if they want to book
the Healy on 4/10 - 4/20, it could tell them that it is not available until
4-15... instead of telling them that the dates "just won't work" - does that
So, using your example, the Healy is booked from 4/1 - 4/15...
When a customer runs a query to find availability, they will select a
start_date of 4/10 and an end date of 4/20
(hehe, I just said 420...)
[one step method]
(of course convert the requested $start_date and $end_date into YYYY-MM-DD
$startsql = " SELECT
count(*) as how_many_booked
((booking_start < '$start_date'
booking_end > '$start_date')
(booking_start < '$end_date'
booking_end > '$end_date'))
villa_id = '$requested_villa_id'";
$query = mysql_query($sql);
$is_it_booked = mysql_fetch_object($query);
print "number of reservations during this date =
This checks if the start date is between the booked dates OR the end date is
between the booked dates
If rows are returned, then the dates are not available.
Does this help?
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php