【发布时间】:2015-10-10 16:07:09
【问题描述】:
我有一个图片库,用户可以在其中将手机中的图片上传到数据库中,然后将其调用到我的图库页面。每个条目在数据库中都有一个 ID、一个图像和一个描述。
这是导出图库的代码:
//include database connection
include 'mysqlconnect.php';
$sql="select * from images order by image desc";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query))
{
$image=$row ['image'];
$description=$row ['description'];
//call all images from DB
echo '<a href="'.$image.'" title="'.$description.'" style="background-image:url('.$image.');"></a>';
}
问题是当用户使用 iPhone 上传照片时。因为 iPhone 总是将其图像保存为“image.jpg”,所以每次上传时都会覆盖图库中以前的 iPhone 图像。我认为这是因为画廊只需要文件名。
有没有办法根据行 ID 调用图像? $image=$row['id','image']; 之类的东西?
【问题讨论】:
标签: php mysql image-gallery