So I am trying to insert some record from one database to another.. So far I have this:
// $records_r = mysqli_fetch_assoc(mysqli_query($conn_r, "SELECT * FROM `TABLE_export` WHERE ID > 100")); If do this -> it inserts only one record
$records_r = mysqli_query($conn_r, "SELECT * FROM `TABLE_export` WHERE ID > 100");
while (mysqli_fetch_array($records_r, MYSQL_ASSOC)) { //I need some while loop, but this is not working
$values_r_implode = implode(",", array_values($records_r)); // I get an error: array_values() expects parameter 1 to be array, object given in
$values_r_array = explode(",", $values_r_implode);
$stmt = $conn_i->prepare("INSERT INTO `TABLE_import` (`COLUMN1`, `COLUMN2`, `COLUMN3`)
VALUES (?,?,?)");
$stmt->bind_param("sss", $value1, $value2, $value3);
$value1 = $values_r_array[0];
$value2 = $values_r_array[1];
$value3 = $values_r_array[2];
$stmt->execute();
}
All I need is to loop trough every new record that I have to insert.