0

I'm trying to show pictures stored in a database but when I run the code, a brunch of text of the picture comes up. (shown in the image below) enter image description here

here's my code for displaying the contents of the database

<?php
include ("connectdb.php");
try {
  $rows = $db -> query("SELECT animal_id, title, animal_dob, animal_type, animal_description,picture_of_animal FROM animals");
    ?> <table>
  <tr>
   <th> Animal id <th> Title </th> <th> Date of birth </th> <th> Type </th><th>Description</th><th>Picture</th>
 </tr> <?php
  foreach ($rows as $rows => $r) {
    ?>
<tr>
 <td><?php echo $r['animal_id']; ?></td>
  <td><?php echo $r['title']; ?> </td>
  <td><?php echo $r['animal_dob']; ?> </td>
  <td><?php echo $r['animal_description']; ?> </td>
  <td><img src "<?php echo $r['picture_of_animal']; ?>" </td>
</tr>
<?php
}
?>

</table>;
<?php
}catch (PDOException $ex) {
  ?>
  <p>Sorry, a database error occurred.</p>
  <p> Error details: <em> <?= $ex->getMessage() ?> </em></p>
<?php
}
?>

Heres a picture of my datatable enter image description here

bola Oyetade
  • 55
  • 2
  • 6
  • 2
    You can't just echo the raw BLOB, you have to either provide a dedicated URL that serves only that one image (with the correct headers), or [inline base64 encode](https://stackoverflow.com/questions/8499633/how-to-display-base64-images-in-html) it. – Alex Howansky May 03 '21 at 15:10

1 Answers1

0

you missed equal sign so add it and alao image close tag

  <td><img src= "<?php echo $r['picture_of_animal']; ?>"/> </td>
Artier
  • 1,648
  • 2
  • 8
  • 22