PHP / MYSQL - Need a loop to return dates on calendar
I have made this table with all the dates of the years going upto 2063, to keep it simple, it contains 3 columns which have been pre-popluated, example as follows...
1) Calendar to select a date
2) A list menu to select the amount of nights they wish to stay.
So I take the original date (the one they select) and rearrange the format to suit the table...
$QueryDate is the date they select
$NightsForQuery is the amount of nights they want to stay
So I set out to establish the first available date in either direction and thts where I got stuck. Looking at it I'm sure you could run a while loop to find the next available block inside the code above, but not sure how.
Which works, but, it selects the previous 4 rows individually.
So for example, if someone tries to book from 2013.06.01 but cant because its 'booked' for the next 4 days, the above script runs and brings up 2013.05.31 - 2013.05.30 - 2013.05.29 - 2013.05.28 as a result.
But if one of those dates are booked it will skip it and give me the next one (selecting as it is the next 4 that meet the condition 'available')
So if say 2013.05.29 was booked it would show 2013.05.31 - 2013.05.30 - 2013.05.28 - 2013.05.27 missing out the day which is booked.
Now the thing is that we need the next 4 rows together (undivided/continuous/without breaks in the dates) which are 'available'.
If you have a better more efficient way or can adapt what is already here, that would be grand... My brain hurts lol.
Thank you, L-Plate
|All times are GMT +1. The time now is 07:35 AM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.