Nemanja Posted April 17, 2015 Share Posted April 17, 2015 want add count rooms.Right now this code is good if hotel has 2 rooms but if hotel has 20 rooms no good. Here is my code <!-- language: lang-php -->$query = "select dates, rooms, COUNT(dates) FROM calendar3 group by dates, dateto, rooms order by dates, rooms"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)) { if($row['COUNT(dates)'] > 2 ){ echo '<font color="#FF4040">'."<br />"."Date ".$row['datefrom']." for this type of rooms is not available". "<br />"."Select another date or room." ; } elseif ($row['COUNT(datefrom)'] <= 2 ) { echo '<font color="#00CC00">'."The rooms are available!"."<br />"; "<br />";<!-- end snippet -->$query = "select dates, rooms, COUNT(dates) FROM calendar3 group by dates, dateto, rooms order by datefrom, rooms"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)) { if($row['COUNT(dates)'] > 2 ){ echo '<font color="#FF4040">'."<br />"."Date ".$row['dates']." for this type of rooms is not available". "<br />"."Select another date or room." ; } elseif ($row['COUNT(dates)'] <= 2 ) { echo '<font color="#00CC00">'."The rooms are available!"."<br />"; "<br />"; Quote Link to comment Share on other sites More sharing options...
IThinkMyBrainHurts Posted April 19, 2015 Share Posted April 19, 2015 1. Put code incode tags! SHows you're a noob othrwise 2. Not seeing anything there that restricts to two rooms! Quote Link to comment Share on other sites More sharing options...
Barand Posted April 19, 2015 Share Posted April 19, 2015 in this code if($row['COUNT(dates)'] > 2 ){ is the "2" the 2 rooms you mentioned? If that is the case then your code isn't good even for 2 rooms. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.