这是我的表单代码:
<?php
$b = 0;
$stmtb = $conn->prepare('SELECT * FROM picture WHERE id = :id');
$stmtb->bindValue(':id', $id, PDO::PARAM_STR);
$stmtb->execute();
while($sb = $stmtb->fetch(PDO::FETCH_ASSOC)) {
$pic = $sb["pic"];
$picid = $sb["picid"];
?>
<img src="/pibgcarta/<?php echo $pic; ?>" height="10%" width="45%" />
<form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']."?dm=".$sch; ?>" id="picform">
<input type="hidden" name="picid" id="picid" value="<?php echo $picid; ?>" class="input_field" role="input" aria-required="true" />
<input type="hidden" name="pic" id="pic" value="<?php echo $pic; ?>" class="input_field" role="input" aria-required="true" />
<input type="submit" value="Padam" class="submit_btn" name="deletepic" id="deletecarta" />
<?php ++$b; } ?>
这是我的邮政编码:
if(isset($_POST['deletepic'])) {
$picid = $_POST["picid"];
$pic = $_POST["pic"];
include "connection.php";
$query = "DELETE FROM picture WHERE picid = :id";
$statement = $conn -> prepare($query);
$statement -> BindParam('id', $picid, PDO::PARAM_INT);
$result = $statement -> execute();
$dpic = "/pibgcarta/".$pic;
unlink($dpic);
}
现在我的问题是,假设有 3 张图片。我按下了第二张照片的删除按钮,但第三张照片被删除了。当我按下第一张照片的删除按钮时,第二张照片被删除。有人可以帮我解决我的问题吗?非常感谢您的帮助。谢谢