What this does is it grabs all items from local table and then inserts them on a remote table, this is supposed to be run at terminal.
<?php
// Connecting to a local database
$con = mysql_connect("localhost","username","password");
mysql_select_db("dbname", $con);
// Selecting all items that are going to be sent to a 2nd server from local table
$result = mysql_query("SELECT * FROM table1");
$count = 0;
while($row = mysql_fetch_array($result)) {
// Cleaning the variables
unset($rowone);
unset($rowtwo);
unset($rowthree);
unset($rowfour);
// Setting the variables
$rowone = $row['rowone'];
$rowtwo = $row['rowtwo'];
$rowthree = $row['rowthree'];
$rowfour = $row['rowfour'];
// Connecting to a remote server and choosing the database
$conx = mysql_connect("my.2nd.server","username","password");
mysql_select_db("dbname", $conx);
// Creating and executing the query
$query = mysql_query("INSERT INTO remotetable1 (rowone, rowtwo, rowthree, rowfour) VALUES ('" . $rowone . "', '" . $rowtwo . "', '" . $rowthree . "', '" . $rowfour . "')");
// Closing the connection to the remote server
mysql_close($conx);
// Displaying it nicely on the terminal
$count++;
echo "$count - $rowone - $rowtwo - $rowfour \n";
}
mysql_close($con);
?>