<html>
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "CSE";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$query = "SELECT * FROM upload WHERE id=1";
$result = $conn->query($query);
while($row = $result->fetch_assoc())
{
header("Content-Type: image/png");
echo '<img height="300" width="300" alt="logo" src="data:image;base64,'.$row["name"].'">';
}
$conn->close();
?>
</body>
</html>
答案 0 :(得分:1)
首先,删除标题。您正在输出HTML,而不仅仅是图片+您已经将HTML发送到浏览器,因此您无法在此之后发送任何其他标头。
然后你需要将blob数据(二进制数据)转换为base64:
test.loc[(test['injury'] == 'A') & (test['crash_drinking'] == 1) & (test['crash_drugs'] == 0)]
test.loc[(test['injury'] == 'A') & (test['crash_drinking'] == 0) & (test['crash_drugs'] == 1)]
test.loc[(test['injury'] == 'A') & (test['crash_drinking'] == 1) & (test['crash_drugs'] == 0) & (test['driver_drinking'] == 1) & (test['driver_drugged'] == 0)]
用于在同一页面上内嵌显示图像的内容。
修改:为了让它更具动感,我还添加了&#34;类型&#34;来自数据库。 (因为你保存了它。)