How to display an available room using date range? below is a code, where is display all the room on that date. its should display a room that had not been booked between two dates.
my input :
$datein = 31-12-2014
$dateout = 01-01-2015
below is database :
---------- room Table (example)
id | name
1 | Home1
2 | Home2
3 | Home3
---------- resinvent Table (example)
resid | id | datein | dateout | status
1 | 1 | 2014-12-31 | 2015-01-01| Active
below is sql code :
<!-- begin snippet: js hide: false -->
<!-- language: lang-html -->
$in = date("Y-m-d", strtotime($_POST['start']));
$out = date("Y-m-d", strtotime($_POST['end']));
$query = mysql_query("SELECT * FROM room WHERE id NOT IN(SELECT * FROM resinvent WHERE (datein <= '$dateout' AND dateout => '$datein' )");
if($query === FALSE)
{
die(mysql_error());
}
while($row = mysql_fetch_array($query))
<!-- end snippet -->
below is html code :
<tr>
<th scope="row">Check In Date</th>
<th scope="row">: </th>
<th scope="row"><input type="text" class="w8em format-d-m-y highlight-days-67 range-low-today" name="start" id="sd" maxlength="10" readonly="readonly"/></th>
<th scope="row"> </th>
</tr>
<tr>
<th scope="row">Check Out Date</th>
<th scope="row">:</th>
<th scope="row"><input type="text" class="w8em format-d-m-y highlight-days-67 range-low-today" name="end" id="ed" maxlength="10" readonly="readonly" /></th>
<th scope="row"> </th>
</tr>
<tr>
<th scope="row"> </th>
<th scope="row"> </th>
<th class="leftbox" scope="row">
<input type="submit" id="submit" value="Check Availability" /></th>