我现在已经尝试了几个小时但仍然没有运气。一旦图像被插入到数据库中,但是当我来到" SELECT"从数据库中所有的图像都是"破碎" 。我使用2个文件,getimage.php和我希望所有图像出现的文件。
查看所有图像
//Connecting Is Here
$SQL = "SELECT * FROM animals LIMIT 50";
$res = mysql_query($SQL);
$numRows = mysql_numrows($res);
$i =0;
while($i < $numRows){
?>
<table width="600" class="blue">
<tr>
<td class="blue">
<p class="white"><?php echo $_GET['ImageId']?><p>
</td>
</tr>
<tr>
<td class="lightblue">
<br>
<div align="center">
<img width="550" src="getimage.php?ImageId=<?php echo mysql_result($res, $i, "ImageId"); ?>"/>
</div>
</td>
</tr>
</table>
<br>
<?php
$i++;
}
?>
GetImage.php
if (IsSet($_GET['ImageId'])){
$gotten = mysql_query("SELECT `Image` FROM `animals` WHERE `ImageId` LIMIT 0 , 30 = ".$_GET['ImageId']);
header("Content-type: image/jpg");
while ($row = mysql_fetch_array($gotten))
{
print $row['image'];
}
mysql_free_result($gotten);
}
?>
答案 0 :(得分:0)
尝试更改
<img width="550" src="getimage.php?ImageId=<?php echo mysql_result($res,$i,"ImageId"); ? > "/>
进入这个:
<img width="550" src="getimage.php?ImageId=<?php echo mysql_result($res,$i,$_GET[ImageId]); ? > "/>
答案 1 :(得分:0)
如果要在一个页面中显示所有图像。您不需要从url获取ImageId。只需直接从您的数据库中获取它。就像这样:
$gotten = mysql_query("SELECT 'Image' FROM 'animals' LIMIT 0 , 30");
while ($row = mysql_fetch_array($gotten)){
print "<img src=\"../images/$row['image']\" />;
}