如何将特定行(查询输出)移动到其他服务器上的另一个数据库?

I have situation like I need to move several rows of data from table in my local database to a remote database. The situation is:

  • I have a php page through which a group can be created and employee data can be uploaded into that group.
  • Then users will choose a group and click a button to move data, I need to move data which related to that group to a database which is on some other remote machine.

that data may be varies from hundreds to several thousand hundreds. Using queries in PHP to select, then delete, then insert into remote machine will take too long time to do this process.

Expecting there could be a better solution for this, but don't know..

Could anybody suggest me how to do this.

Hope I understand what you are trying to get at? I am amusing you know PHP. When the page loads query the first DB and use results to populate form fields. When the form is submitted you can than insert the data into the next DB. You can do this all from one page.

Example query on page load

include '../connect-db.php';
$query = "SELECT * FROM `DB`
        WHERE id='".$mysqli->real_escape_string($_REQUEST['id'])."'
        limit 0,1";

//execute the query
$result = $mysqli->query( $query );

//get the result
$row = $result->fetch_assoc();

//assign the result to certain variable so our html form will be filled up with values
$id = $row['id'];
$name = $row['name'];

populated HTML Form

<form action=# method='post' name=ra id=ra>
<table>
    <tr>
    <th><h1 class='whatever'><?php echo $name;?></h1></th>
    </tr>
    <tr>
    <input type='hidden' name='action' value='update' /> 
            <input type='submit' value='Update' /></td></tr></table>

Insert Query on submit

if($action=='update' ){
include '../connect-new-db.php';

$query = "insert into `DB` 
    set
        `name` = '".$mysqli->real_escape_string($_POST['name'])."',
        `link` = '".$mysqli->real_escape_string($_POST['link'])."'";

//execute the query
if( $mysqli->query($query) ) {
//if saving success
echo "<h2>The data has been added.</h2>";
}else{
//if unable to create new record
echo "<h2>There has been an error adding the data</h2>";
}
}

Hope that Helps