<?php
try{
include("dbconnectie.php");
$query = $db->prepare("SELECT * FROM shop WHERE id_img = '3'");
$query->execute();
$result = $query->fetchALL(PDO::FETCH_ASSOC);
$image = $result['img_url'];
echo "<table>";
foreach($result as &$data) {
echo "<tr>";
echo "<td>" . $data["brand"] . "</td>";
echo "<td>" . $data["model"] . "</td>";
echo "<td>" . $data["cond"] . "</td>";
echo "<td>" . $data["price"] . "</td>";
echo '<img src="data:image/png;base64,'.base64_encode( $data["image"] ).'"/>';
echo "</tr>";
}
echo "</table>";
} catch(PDOException $e) {
die("Error!: " . $e->getMessage());
}
?>
<html>
<body>
<a src='<?php echo $image; ?>' border='0'></a>
</body>
</html>
第7行中的你可以看到我正在尝试将$ image定义为保存在数据库中的url,这样我就可以在底部使用它将其作为图像投影。