I plan to have a local version of same app with same database structure. A duplicate of the app offline to be used when there is no wifi . i want to data to be synched with remote server by just clicking a button (obviously a custompage with the code to push data will load when the button is clicked).Thank you
I do something similar and it is fairly easy if both databases have the same login/password.Example below is just for one table but you could expand it. I just use a PHPM menu item to run the php file directly.
This example is copying the table tblmembers from the d/b phouse_members to the d/b phouse_bartabs
// Create a new MySQL database connection
if (!$con = new mysqli('localhost', $username, $password, $database)) { // this is the destination database - phouse_bartabs
die('An error occurred while connecting to the MySQL server!<br><br>' . $con->connect_error);
}
// Create an array of MySQL queries to run
$sql = array(
'Use phouse_bartabs;',
'drop table tblmembers;',
'create table tblmembers like phouse_members.tblmembers;',
'insert into tblmembers select * from phouse_members.tblmembers;'
);
// Run the MySQL queries
if (sizeof($sql) > 0) {
foreach ($sql as $query) {
if (!$con->query($query)) {
die('A MySQL error has occurred!<br><br>' . $con->error);
}
}
}
$con->close();