循环未完成

发布于 2025-01-04 15:52:13 字数 591 浏览 1 评论 0原文

在这里我写了一个小代码...在此循环中未完成..仅显示第一张图像..实际上有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

随梦而飞# 2025-01-11 15:52:13

你的数据库里到底有什么?如果存在图像路径,则应像

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.

烧了回忆取暖 2025-01-11 15:52:13

试试这个:

<?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
}
?>

try this:

<?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
}
?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文