php - Search Query don't show results -


i have search engine problem search engine don't show search results, connections database correct here code:

php :

if (isset($_post['search'])) { $searchq = $_post['search']; $searchq = preg_replace("#[^0-9a-z]#i", "", $searchq); $query = mysql_query("select * treference sreference '%$searchq%' or ssearch '%$searchq%' or ssort '%$searchq%'") or die("la recherche est impossible"); $count = mysql_num_rows($query);   if ($count == 0) {     $output = "aucun résultat pour cette recherche!";               //english trans : no results have been found!  } else  {         $sreference = $count['sreference'];         $output.= '<div><ul><li><a target="_blanc" href="refrences.php?reference=' . $sreference . '" title="' . $sreference . '">' . $sreference . '</a></li></ul></div>'; }  } 

html:

<div id="searchd"> <div class="searchc"> <form action="reference.php" method="post"> <input type="text" name="search" palceholder="recherhcer..."> <input type="submit" value="ok"> <div class="clear"></div> </form> </div> <div id="output"> <?php echo ($output); ?> </div> </div> 

and in advance!

you not processing result of query. have fetch each row returned result set , use fields returned in html output.

try this:-

if (isset($_post['search'])) {     $searchq = $_post['search'];     $searchq = preg_replace("#[^0-9a-z]#i", "", $searchq);     $query = mysql_query(         "select * treference           sreference '%$searchq%' or                 ssearch '%$searchq%' or                 ssort '%$searchq%'") or die("la recherche est impossible");      if (mysql_num_rows($query) == 0) {         $output = "aucun résultat pour cette recherche!";               //english trans : no results have been found!     } else {          $output .= '<div><ul>';         while ( $row = mysql_fetch_object($query) ) {             $output .= '<li>';             $output .= '<a target="_blanc" href="refrences.php?reference=' . $row->sreference . '" ';              $output .= '" title="' . $row->sreference . '">' . $row->sreference . '</a>';             $output .= '</li>';         }         $output .= '</ul></div>';     }  } 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -