Hi guys
I have a mysql db that stores booked/available dates and I am trying to search it using a start date and duration of X days like this
$start_y = $_REQUEST['start_year'];
$start_m = $_REQUEST['start_month'];
$start_d = $_REQUEST['start_day'];
$duration = $_REQUEST['duration'];
$start = "$start_y-$start_m-$start_d";
$end1 = strtotime($start.' + '.$duration.' day');
$end = date("Y-m-d", $end1);
$diff = strtotime($end) - strtotime($start); //Find the number of seconds
$difference = floor($diff / (60*60*24)) ; //Find how many days that is
Then the query
SELECT propname, count( num ) AS days
FROM bookings WHERE STATUS =1
AND day_booked BETWEEN '$start' AND '$end' GROUP BY num
From here I want to display to the end user the rooms available for their chsoen date and duration like this
None available (if mysql returned zero rows)
RoomX available for your chosen duration (date + the duration they chose IE 2 or 3 days)
OR RoomX available for 2 of your chosen days (they may have asked for 3 days/nights)
What is the best way to do the above, STATUS=1 if the room is available or =0 if already booked.
Thanks in advance to any help