Michdd Posted November 6, 2008 Share Posted November 6, 2008 What would the statement look for when I'm using $result = mysql_query("SELECT * FROM pets WHERE id='$id' ") or die(mysql_error()); And if id='$id' doesn't exist in the database, how would I make it return, "There is no such row"? Link to comment https://forums.phpfreaks.com/topic/131679-if-not-found-in-the-database/ Share on other sites More sharing options...
rhodesa Posted November 6, 2008 Share Posted November 6, 2008 $result = mysql_query("SELECT * FROM pets WHERE id='$id' ") or die(mysql_error()); if(!mysql_num_rows($result)){ echo "There is no such row"; }else{ $row = mysql_fetch_array($result); } Link to comment https://forums.phpfreaks.com/topic/131679-if-not-found-in-the-database/#findComment-684036 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.