Anyhow, am after a solution for this headscratcher if possible.
Scenario: I have holiday booking site two calendars to select a To and From date. These are fed into a function, along with a selected resortID and accommodationID.
In my accommodationDetails table, I have
ID resortID fromDate toDate accommodationnameID cost
The two ID's are for lookup tables and the dates are in unix timestamp format.
I have converted the fed in $FromDate and $ToDate into unix dates and worked out the number of nights between them by
Code: Select all
$secondsLeftOver = $ToDate - $FromDate;
$turnIntoDays = intval($secondsLeftOver / 86400);
$nightsStay = $turnIntoDays - 1;
Now this could be done by using a sql call that has a WHERE $FromDate is => than fromDate and < toDate sort of idea but the catch is that each accommodation has multiple dates and costs which differ.
ie
Flat A Nov14-Dec20 = £79 Dec21-Dec26 = £87 etc etc
and the booking could go over these boundaries, ie how do I search if the fromDate is Dec20 and toDate is Dec24?
thanks in advance
frank