• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

PHP +Mysql question

Eagle710

OSNN Senior Addict
#1
I am making a site that books cottage rentals. On my booking page i accept a check in and check out date i verify that they are valid dates, not in the past and that the Checkout date is greater then the check in. Im stuck now because i have to check my availability table to see if those days interfere with someone else's booking. I am having a hard time so i turn to you people of OSNN. Please. Is there a function that checks for overlapping in php or mysql. Or does anyone know some code to fix this problem. Thanks.
 
#2
Something along the lines of

SELECT * FROM bookings WHERE cottage = '5' AND checkin BETWEEN :client_checkin AND :client_checkout AND checkout BETWEEN :client_checkin AND :client_checkout;

Replacing :client_checkin and :client_checkout with the checkin/checkout dates specified by the client. Try throwing that SQL at some test data and see if you get the response you are looking for.
 

Eagle710

OSNN Senior Addict
#3
That somewhat works but if the "stupid" client was to put a day in between the Arrival and Departure Date? i checked and that would fail the test. I'm surprised MYSQL doesn't just have function.
 

Members online

No members online now.

Latest posts

Latest profile posts

Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,961
Messages
673,239
Members
89,017
Latest member
loxioalix