How can I show a message when no rows have been selected in mysql, php?

mysql, php

Solution

try

if (mysql_num_rows($result) == 0) {
  // Show message
} else {
  // do your while stuff here
}

Problem

My code looks like this: ``` $result = mysql_query("SELECT * FROM `picdb` WHERE `picid` = '$picid' ") or trigger_error(mysql_error()); while($row = mysql_fetch_array($result)){ foreach($row AS $key => $value) { $row[$key] = stripslashes($value); } ``` Problem is that when there is no row to select, nothing happens, my $row array is empty. How can i have this present a message of "no row found" when no rows match the select?

Original source