Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling different function for different search Option
    primarykey
    data
    text
    <p>Dear Friend i have two function and maybe i might have more in the future but the point is that i want when a user searches for hotel based on postal code on the same text field the function hotel_by_postel_code($textvalue) should be called and when i search based on country then the function hotel_by_country($textvalue) should be called. the following is the code that should displays the result however it is not displayong the result as it should at all.</p> <pre><code>&lt;?php require_once("includes/header.php");?&gt; &lt;?php require_once("includes/connection.php")?&gt; &lt;?php if(isset($_POST['submit'])){ $message =""; $textvalue = $_POST['search']; if(empty($allhotels = hotel_by_postel_code($textvalue)) || empty($allhotels = hotel_by_country($textvalue))){ $message = "There is no record in the database"; } }else{ $allhotels = select_all_hotels(); } ?&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="list2.php" method="POST" id="searchForm"&gt; &lt;fieldset&gt; &lt;input type="text" name="search" /&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;?php if(isset($message)){ echo"&lt;div id=\"listtitle\"&gt;"; echo"&lt;h2&gt;".$message."&lt;/h2&gt;"; echo"&lt;/div&gt;";//End of listtitle div }else{ echo"&lt;div id=\"listtitle\"&gt;"; echo"&lt;h2&gt;Property Name&lt;/h2&gt; &lt;h2&gt;Location&lt;/h2&gt; &lt;h2&gt;Guest Rating&lt;/h2&gt;&lt;h2&gt;Hotel Rank&lt;/h2&gt;&lt;h2&gt;Per night&lt;/h2&gt;"; echo"&lt;/div&gt;"; } ?&gt;&lt;!--End of listtitle--&gt; &lt;div class="cBoth"&gt;&lt;/div&gt; &lt;?php $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 =\"#\"&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++; }//end of if() }//end of hotel while mysql_close($con); ?&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> <p>and the following code is the function itself</p> <pre><code>function hotel_by_country($country){ global $connection; $query = "SELECT * FROM Hotels WHERE country ='{$country}'"; $hotel_set = mysql_query($query,$connection); confirm_query($hotel_set); return $hotel_set; } function hotel_by_postel_code($postal){ global $connection; $query = "SELECT * FROM Hotels WHERE hotel_postal_code ='{$postal}'"; $hotel_set = mysql_query($query,$connection); confirm_query($hotel_set); return $hotel_set; } function select_all_hotels(){ global $connection; $query = "SELECT * FROM Hotels"; $hotel_set = mysql_query($query,$connection); confirm_query($hotel_set); return $hotel_set; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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