Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Available days

find amount of days available for booking calendar

2:08 pm on May 23, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 6, 2005
votes: 0

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
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

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members