homepage Welcome to WebmasterWorld Guest from 54.204.59.230
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

    
Available days
find amount of days available for booking calendar
wheelie34




msg:4577021
 2:08 pm on May 23, 2013 (gmt 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
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

 

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved