php - If search returns nothing give error -


i have search form on website, , want return error if user searches not exist in database

<?php  $search = $_post['search' ];  $numrows = mysql_num_rows ($result );  if($numrows != 0) echo "no results"; ?> 

this code search form using, echo"no results" shows on homepage above of results, not display when there no results search.

i'm beginner php, unsure why happening.

if need full code, below:

http://pastebin.com/xjxwhfdt

wouldn't

if($numrows == 0) echo "no results"; 

if nothing found ?

  • your $numrows = mysql_num_rows ($result ); shouldn't @ place is.

you should :

$count = count($result); if($count > 0) {     while ($row =mysql_fetch_object ($result)) {         // stuff     } } else {     echo 'no results'; } 

also, point of $search = $_post['search' ]; in while loop? don't seem use @ all.


Comments

Popular posts from this blog

java - Incorrect order of records in M-M relationship in hibernate -

command line - Use qwinsta in PowerShell ISE -

php - I want to create a website for polls/survey like this http://www.poll-maker.com/ -