我在单个ID中添加的图像多于图像但是如果删除了删除按钮中的图像。只有一个图像删除该文件夹剩余图像不删除该文件夹。如何删除剩余的图像??????
$sql = mysql_query("select * from urbanesqe_completed_image WHERE id ='".$_GET['del']."'");
////echo "select * from urbanesqe_completed_image WHERE id ='".$_GET['del']."'";
$res = mysql_fetch_array($sql);
$product_image = $res['product_image'];
$image_path = "../images/completed/".$product_image;
unlink($image_path);
mysql_query("DELETE FROM urbanesqe_completed WHERE id ='".$_GET['del']."'");
mysql_query("DELETE FROM urbanesqe_completed_image WHERE id ='".$_GET['del']."'");
答案 0 :(得分:1)
如果urbanesqe_completed_image
表中有多条记录,则按
while($res = mysql_fetch_array($sql)){
$product_image = $res['product_image'];
$image_path = "../images/completed/".$product_image;
unlink($image_path);
}
所以它会删除所有图像
答案 1 :(得分:-2)
您需要在循环中调用mysql_fetch_array
。 the manual