【发布时间】:2013-02-04 18:19:45
【问题描述】:
php
include("connect_to_database.php");
if( !isset($_FILES["image"]) ){
echo "upload the file";
}else{
$image = mysql_query("SELECT * FROM upload WHERE id=1");
$image = mysql_fetch_assoc($image);
$image = $image["image"];
echo $image;
}
html
<form action="newindex.php" method="POST" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit" value="Upload" >
</form>
上面的代码显示了已经以BLOB格式上传到mysql中的相应id的图像。
现在,我需要显示最后 6 个 id 的图像或数据库中的所有图像。我已经尝试了下面的代码,但它不工作,而是显示 1 个图像。
php
include("connect_to_database.php");<br>
$query = mysql_query("SELECT * FROM upload ORDER BY id DESC");
while( $rows = mysql_fetch_array($query) ){
$image = $rows["image"];
header("Content-type: image/jpeg");
echo $image."<br/>";
}
【问题讨论】:
-
好吧,你显然不能将所有图像连接到一个文件中。