I want the code to Search the database for rooms already booked on the date required.
for example. I have 5 Double Standard Rooms available, when the customer pushes submit it needs to search for booking between the dates that they wish to book. If all 5 rooms are booked then return a page saying so, if rooms are avalable then continue to book the room.
this is the code i have atm
for example. I have 5 Double Standard Rooms available, when the customer pushes submit it needs to search for booking between the dates that they wish to book. If all 5 rooms are booked then return a page saying so, if rooms are avalable then continue to book the room.
this is the code i have atm
Code:
$query = "select roomNo, price from Room where type= '$roomType'";
$result = mysql_query($query);
$getTotalRecords = mysql_num_rows($result);
$i = 0;
while($row = mysql_fetch_array($result)){
$i++;
$query1 = "select * from Reservations where roomNo = '{$row[0]}'";
$result1 = mysql_query($query1);
$row1 = mysql_fetch_array($result1);
if($row1) {
if($startDate >= $row1['dateIn'] && $startDate <= $row1['dateOut'] ||
$finishDate >= $row1['dateIn'] && $finishDate <= $row1['dateOut']) {
if($i == $getTotalRecords){
echo "All rooms are booked at the moment. Please go back and choose another period.";