[英]Move image from one table to another using button
I am creating a button that will allow an admin to verify the image from users:我正在创建一个按钮,允许管理员验证来自用户的图像:
I don't know how to get the image ID when I click accept or reject.当我点击接受或拒绝时,我不知道如何获取图像 ID。
Here's my code:这是我的代码:
<?php
while($row = mysqli_fetch_array($result)) {
echo "<div class='grid-item'><img src='unimages/{$row['un_image']}'
onclick=onClick(this) style='width:98%' class='verifyimage' />
<form method='post' action='adminverify.php'>
<input class='button1' type='submit' name='accept' value='✓'>
<input class='button2' type='submit' name='reject' value='✘'>
</form>
</div>
";
}
mysqli_close($db);
?>
</div>
If the admin accepts, then the image should move from table2 to table1.如果管理员接受,则图像应从 table2 移动到 table1。
I know using INSERT INTO
and DELETE
will work, but how do I get the id for my picture.我知道使用
INSERT INTO
和DELETE
会起作用,但是如何获取我的图片的 ID。
Table 1:表格1:
Table 2:表 2:
Mmmh, you can use GET method for easier script:嗯,您可以使用 GET 方法来简化脚本:
while($row = mysqli_fetch_array($result)) {
echo "
<a href='?&action=accept&id={$row['un_id']}'>Accept</a>
<a href='?&action=reject&id={$row['un_id']}'>Reject</a>
";
}
And you use it like :你像这样使用它:
if(isset($_GET['action']) && isset($_GET['id'])) {
$image_id = $_GET['id']
// Then check if you must accept or reject with $_GET['action'] value
}
I'd add a hidden input that will be sent with the form:我将添加一个将与表单一起发送的隐藏输入:
echo "<div .....
<form....>
<input type='hidden' name='imageId' value='{$row['un_id']}'>
....
</form></div>";
You'll then have it in your receiving php script as然后,您将在接收的 php 脚本中将其作为
$image_id = $_POST['imageId'];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.