PHP +Mysql question

Eagle710

OSNN Senior Addict
Joined
13 Mar 2005
Messages
312
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.
 
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.
 
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 profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back