从MySql数据库到html的图像(通过php)“ BLOB”

时间:2018-07-19 19:41:39

标签: php html mysql database

我有问题,如何在html中显示来自Mysql数据库的图像(.jpg)。图像由BLOB存储在MySql数据库中。 我是初学者。我试图显示从表“ koncove_prvky”到html表的所有内容。 文字还可以,但是我不知道如何更改/添加用于显示html图像的代码... 将图像附加到名称为“ image”的结构上。 插入的php skript用于显示数据库中的表是...

 <?php
$con=mysqli_connect("something.net","a125787_prvky","Passworld","d125787_prvky");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM koncove_prvky");

echo "<table border='1'>
<tr>
<th>id</th>
<th>obrazek</th>
<th>nazev</th>
<th>typ</th>
<th>info</th>
<th>vyrobce</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['image'] . "</td>"; // this is type BLOB, but what i must do with it for display it? :)
echo "<td>" . $row['nazev'] . "</td>";
echo "<td>" . $row['typ'] . "</td>";
echo "<td>" . $row['info'] . "</td>";
echo "<td>" . $row['vyrobce'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>

0 个答案:

没有答案