循环未完成


looping is not done

这里我写了一个小代码。。。在这个循环中没有完成。。仅显示第一个图像。。实际上有7张图片。。。请帮我处理这个

 <?php
$username = "root";
$password = "root";
$host = "localhost";
$database = "test";
error_reporting(E_ERROR | E_PARSE);
mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());
mysql_select_db($database) or die("Can not select the database: ".mysql_error());

header('Content-type: image/jpg');
$query = mysql_query("SELECT * FROM tbl_images");
while($row = mysql_fetch_array($query))
{
echo $content = $row['image']."</br>";
echo $content;
}
?>

数据库中的实际内容是什么?如果有一个图像的路径,你应该像一样输出它

echo '<img src="'.$row['image'].'">';

如果有带图像的blob数据,则只能使用header('Content-type: image/jpg');输出其中一个。这样您就可以创建一个页面来打印所需的图像。

试试这个:

<?php
error_reporting(E_ERROR | E_PARSE);
$username = "root";
$password = "root";
$host = "localhost";
$database = "test";
mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());
mysql_select_db($database) or die("Can not select the database: ".mysql_error());
//header('Content-type: image/jpg');
$query = mysql_query("SELECT * FROM tbl_images");
while($row = mysql_fetch_array($query)){
    echo '<img src="'.$row['image'].'" width=40 height=40>';// remove width and height later
}
?>