-3

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

2 回答 2

1

如果表中有多个记录,urbanesqe_completed_image则进行循环,例如

while($res = mysql_fetch_array($sql)){
  $product_image = $res['product_image'];
  $image_path = "../images/completed/".$product_image;
  unlink($image_path);
}

所以它将删除所有图像

于 2012-04-25T11:31:47.823 回答
-2

您需要mysql_fetch_array循环调用。手册中有一个例子

于 2012-04-25T11:28:56.267 回答