这里我写了一个小代码......在这个循环中没有完成..只有第一张图片正在显示..实际上有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;
}
?>
答案 0 :(得分:2)
您的数据库中的实际内容是什么?如果有图像路径,则应输出
echo '<img src="'.$row['image'].'">';
如果有带图像的blob数据 - 您只能使用header('Content-type: image/jpg');
输出其中一个。这样你就可以创建一个可以打印所需图像的页面。
答案 1 :(得分:1)
试试这个:
<?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
}
?>