使用PHP移动MySQL行

I have a MySQL database.

Members are loaded that are active.

The tables are somewhat like this:

Table Name: recipients

Columns:    recipient_id
            member_id

Then I have a table named recipients_banned The columns are the same as in recipients.

What I want to do is have a yes/no field in a form (PHP) that, when clicked, moves all the people with member_id in recipients table to recipients_banned table.

Any assistance with some initial code for this would be appreciated. Is this at all possible without deleting all of the data? Please note that the rows in recipients should be deleted once moved.

recipients                     recipients_banned

recipient_id | member_id       recipient_id | member_id
------------------------       ------------------------
11           | 21              31           | 32
21           | 22              41           | 42

Actually, you didn't explain your question in detail. So, I have tried to guess something about your question and give you some tips. For example, we have a PHP file with a name of form.php:

<form action="form.php?q=yes" method="get">
  Recipient ID: <input type="text" name="recipient_id">
  Member ID: <input type="text" name="member_id">
  <input type="submit" value="Move">
</form>

<?php
$con = mysqli_connect("$host", "$user", "$password", "$database");

$r = mysql_real_escape_string($_GET["recipient_id"];
$m = mysql_real_escape_string($_GET["member_id"];
$q = $_GET["q"];

if ($q = yes) {
    $i = "INSERT INTO `recipients_banned` ( `recipient_id` , `member_id` )
    VALUES (
      '$r' , '$m'
    );";

    $d = "DELETE FROM `recipients` WHERE `recipient_id` = $r AND `member_id` = '$m' LIMIT 1;";

    mysqli_query($con, "$i
    $d");
}

mysqli_close($con);
?>

If we try to input "21" in Recipient ID field and "22" in Member ID field and then click the Move button, the database tables' contents would look like this:

recipients                     recipients_banned

recipient_id | member_id       recipient_id | member_id
------------------------       ------------------------
11           | 21              21           | 22
                               31           | 32
                               41           | 42

Feel free to revise this answer if something isn't right!

Your question wasn't clear.. For example, the data of our tables are:

recipients               | recipients_banned
recipient_id | member_id | recipient_id | member_id
------------------------ | ------------------------
1            | 21        |
2            | 22        |

If you just want to have "Yes" and "No" radio buttons on a form that when you've selected the "Yes" button and then submitted, all the data in recipients table will be moved into the recipients_banned table, then you should better try this code. For example we've a PHP file named as form.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);
?>

If you select "No" and then submit it, the output will be "Nothing is moved!". But if you select "Yes" before submitting it, the database tables result which is unseen will become as the tables below with an output of '"recipients" data is moved to "recipients_banned"!':

recipients               | recipients_banned
recipient_id | member_id | recipient_id | member_id
------------------------ | ------------------------
                         | 1            | 21
                         | 2            | 22