循环未完成
在这里我写了一个小代码...在此循环中未完成..仅显示第一张图像..实际上有 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;
}
?>
Here i have written a small code...in this looping is not done..only first image is displaying..Actually there are 7 images...Please help me on this
<?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;
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的数据库里到底有什么?如果存在图像路径,则应像
echo '';
一样输出它,并且如果存在带有以下内容的 blob 数据图像 - 您只能使用
header('Content-type: image/jpg');
输出其中一个图像。这样您就可以创建一个打印所需图像的页面。what is actualy in your database? if there's a path to image, you should output it like
echo '<img src="'.$row['image'].'">';
and if there's a blob data with an image - you can only output one of them using
header('Content-type: image/jpg');
. so you can create a page which will print desired image.试试这个:
try this: