Log in

View Full Version : if No results then post error



Rockonmetal
04-20-2008, 09:32 PM
I am looking for a way to have it so if someone searches for something and it doesn't exist... It will say something like "We don't have it..."
I am using a search thing i made which uses PHP and MySQL... When there are results it works but when there aren't results there isn't even an error...
Once again I am using PHP and MySQL to make my site so I can't use ASP or other server scripts...
Thanks in advance!

Nile
04-20-2008, 09:40 PM
Well, you can use mysql_num_rows, so try this:


if(mysql_num_rows($result) == 0){
die('No results.');
}

If you want it to die, or you can do something like this:


if(mysql_num_rows($result) == 0){
echo 'No results';
} else {
//while()
}