I am grabbing entries from a database and displaying them on my web page like so:
$query = mysql_query("SELECT * FROM posts order by id desc") or die(mysql_error());
if (!$query) {
die('MySQL error');
} else {
while($row = mysql_fetch_array($query)):
// HTML stuff with <?php echo $row['title']; ?>
endwhile; }
How can I write a if statement to echo “Nothing Found” if there are no entries to get? So basically, if the query does its thing and finds nothing, how can I echo some sort of “error message”?
You can use: