我有一个工作代码,它从MYSQL表中提取图像blob并在我的网页上显示它们。它适用于大多数情况,但我遇到的问题是如何不移动到下一行,如下图所示。反正有吗?
<?php
$id ='1';
$db = mysqli_connect("localhost","brianrob_usr","","brianrob_productdb"); //keep your db name
$sql = "SELECT * FROM Products WHERE id = $id";
$sth = $db->query($sql);
while($row = $sth->fetch_array()){
echo '<div><img src="data:image/jpeg;base64,'.base64_encode( $row['Image'] ).'"/></div>';
}
?>
@charset "utf-8";
/* CSS Document */
body{
width: inherit;
height:inherit;
background-image: url("007-dark-loom.png");
}
答案 0 :(得分:1)
由ADyson指定,删除标签有助于解决此问题。
<?php
$id ='1';
$db = mysqli_connect("localhost","brianrob_usr","Ilikecandy2009","brianrob_productdb"); //keep your db name
$sql = "SELECT * FROM Products WHERE id = $id";
$sth = $db->query($sql);
while($row = $sth->fetch_array()){
echo '<img src="data:image/jpeg;base64,'.base64_encode( $row['Image'] ).'"/>';
}
?>