conditional user feedback

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cauri
Forum Newbie
Posts: 4
Joined: Thu Feb 26, 2004 9:04 am

conditional user feedback

Post by cauri »

new to php mysql

When a database query returns no results, what is the best way to use php to redirect to another page or to display "nothing found" instead of the results?

cauri
[/google]
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Code: Select all

$res=mysql_query("SELECT something FROM something_else");
if(mysql_num_rows($res)<1)
   echo "<span style='color: red; text-align:center'>Sorry, nothing found ;(</span>";
else {
  //display your results here
}
:D
Post Reply