Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>After many trail and error i was able to come to the solution and the following is the best option i found maybe in the future someone my come up with the same problem. one thing to keep in mind is that the options in IF and Else can easily be moved into a function on separate file. and i also added one more Html menu to select the type of option i am search for in this case it is the filter menu.</p> <pre><code>&lt;?php error_reporting(E_ALL); ini_set('display_errors','1');?&gt; &lt;?php require_once("includes/header.php");?&gt; &lt;?php require_once("includes/connection.php")?&gt; &lt;?php if(isset($_POST['search']) &amp;&amp; $_POST['search']!= "") { if($_POST['filter'] == "HotelName"){ $search = $_POST['search']; $sqlquery = "SELECT * FROM Hotels WHERE hotel_name LIKE '%$search%' OR description LIKE '%$search%'"; $allhotels = mysql_query($sqlquery, $connection) or die("Sorry Something wrong".mysql_error()); }else if($_POST['filter'] == "country"){ $search = $_POST['search']; $sqlquery = "SELECT * FROM Hotels WHERE country LIKE '%$search%' OR hotel_address LIKE '%$search%'"; $allhotels = mysql_query($sqlquery, $connection) or die("Sorry Something wrong".mysql_error()); }else if($_POST['filter'] == "Postal"){ $search = $_POST['search']; $sqlquery = "SELECT * FROM Hotels WHERE hotel_postal_code LIKE '%$search%'"; $allhotels = mysql_query($sqlquery, $connection) or die("Sorry Something wrong".mysql_error()); } } ?&gt; &lt;div class="cBoth"&gt;&lt;/div&gt; &lt;div id="sep"&gt;&lt;/div&gt; &lt;div id="mainContentSection" class="Calign"&gt; &lt;div id="detaillist"&gt; &lt;div id="searching" class="Calign"&gt; &lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="POST" id="searchForm"&gt; &lt;fieldset&gt; &lt;input type="text" name="search" /&gt; &lt;select name="filter"&gt; &lt;option value="HotelName"&gt;Hotel Name&lt;/option&gt; &lt;option value="country"&gt;Country&lt;/option&gt; &lt;option value="Postal"&gt;Postal Code&lt;/option&gt; &lt;/select&gt; &lt;input type="submit" name ="submit" value="Search" /&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;/div&gt;&lt;!--End of searching--&gt; &lt;div id="listtitle"&gt; &lt;h2&gt;Property Name&lt;/h2&gt; &lt;h2&gt;Location&lt;/h2&gt;&lt;h2&gt;Hotel Rank&lt;/h2&gt;&lt;h2&gt;Guest Rating&lt;/h2&gt;&lt;h2&gt;Per night&lt;/h2&gt; &lt;/div&gt;&lt;!--End of listtitle--&gt; &lt;div class="cBoth"&gt;&lt;/div&gt; &lt;?php if(!isset($allhotels)){ $allhotels = select_all_hotels(); } $i=0; while($hotels_set = mysql_fetch_array( $allhotels)){ $room_rate = rateforhotel($hotels_set['hotel_id']); if(!empty( $hotels_set['hotel_name']) &amp;&amp; ($room_rate['hotel_id'] == $hotels_set['hotel_id'] ) ){ if($i % 2 == 0) { echo "&lt;div id=\"innerlisteven\"&gt;"; } else { echo"&lt;div id=\"innerlistodd\"&gt;"; } echo"&lt;h2&gt;&lt;a href=\"desti_list.php?details=" . urlencode($hotels_set["hotel_id"]). "\"&gt;" . $hotels_set['hotel_name'] ."&lt;/a&gt;&lt;/h2&gt;"; echo"&lt;h2&gt;". $hotels_set['country'] ."&lt;/h2&gt;"; if(!intval($hotels_set['star'])){ echo"&lt;h2&gt;". $hotels_set['star'] ."&lt;/h2&gt;"; }else{ echo"&lt;h2&gt;". $hotels_set['star'] . "&lt;img src=\"img/repetimg/star.png\"/&gt;&lt;/h2&gt;"; } echo"&lt;h2&gt;". $hotels_set['star'] . "&lt;/h2&gt;"; echo"&lt;h2&gt;". $room_rate['rate'] . "&lt;/h2&gt;"; echo"&lt;/div&gt;"; $i++; /* echo"&lt;h3&gt;&lt;a href=\"desti_list.php?details=" . urlencode($hotels_set["hotel_id"]). "\"&gt;Find Out More&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;"; */ }//end of if() }//end of hotel while mysql_close($connection); ?&gt; &lt;/div&gt;&lt;!--End of details--&gt; &lt;div id="advertlisting"&gt; &lt;div id="search"&gt;search menu&lt;/div&gt; &lt;/div&gt;&lt;!--End of adverts left--&gt; &lt;/div&gt;&lt;!--End of end of maincontent--&gt; &lt;div class="cBoth"&gt;&lt;!-- clear Both--&gt;&lt;/div&gt; &lt;?php require_once("includes/footer.php"); ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload