您的问题不清楚。例如,我们表格的数据是:
recipients | recipients_banned
recipient_id | member_id | recipient_id | member_id
------------------------ | ------------------------
1 | 21 |
2 | 22 |
如果您只想在表单上有“是”和“否”单选按钮,当您选择“是”按钮然后提交时,收件人表中的所有数据都将移动到收件人禁止表中,那么您应该最好试试这段代码。例如,我们有一个名为form.php的 PHP 文件:
<form action="form.php" method="get">
<input type="radio" name="q" value="1">Yes<br />
<input type="radio" name="q" value="0">No
<input type="submit" value="Submit">
</form>
<?php
$con = mysqli_connect("$host", "$user", "$password", "$database");
$q = $_GET["q"];
if ($q == 1) {
$i = "INSERT INTO `recipients_banned` ( `recipient_id` , `member_id` )
SELECT recipient_id , member_id
FROM `recipients`;";
$d = "DELETE FROM `recipients`;";
mysqli_query($con, "$i
$d");
echo '"recipients" data is moved to "recipients_banned"!';
} else if ($q == 0) {
echo "Nothing is moved!";
}
mysqli_close($con);
?>
如果选择“No”然后提交,输出将是“Nothing ismoved!” . 但是,如果您在提交之前选择“是”,则看不见的数据库表结果将变为下表,并输出“收件人”数据已移动到“收件人禁止”!:
recipients | recipients_banned
recipient_id | member_id | recipient_id | member_id
------------------------ | ------------------------
| 1 | 21
| 2 | 22