[英]Pictures are not displaying from database
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) (如下图所示)
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
}
?>
you missed equal sign so add it and alao image close tag你错过了等号所以添加它和alao图像关闭标签
<td><img src= "<?php echo $r['picture_of_animal']; ?>"/> </td>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.