I have a mysql database with text and image (blob) information stored in it. I want to show all this information in a page using a PHP script, my problem is that not every inserted data contains image, so… when the PHP script is ran and there is an image stored on the database it shows correctly but when there is no image stored it displays a broken image symbol on the browser… How I can solve this so that the images are displayed when they exists on the database and avoid the broken image symbol when there is not?
My code is the following:
echo '<body bgcolor="#ffffff">';
echo "<p style='color:white;background-color:blue;font-family:arial black;font-size:20;text-align:center'>". $row['title'] . "</p>";
echo '<center><img src="data:image/jpeg;base64,'.base64_encode( $row['image'] ).'" width="300" eight="300"/></center>';
echo "<br>";
echo "<br><br>";
echo '<font size="3"><b><i>POR:' . $row['author'] . '</font></i></b><br>';
echo '<font size="3"><b><i>DATA: ' . $row['date'] . '</font></i></b><br><br>';
echo '<font size="3">' . $row['text'] . '</font><br>';
echo "<hr><hr>";