图像取消链接在PHP中

时间:2012-04-25 11:19:29

标签: php

我在单个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']."'");

2 个答案:

答案 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_arraythe manual

中有一个例子