V
V
viktorross2020-02-27 17:53:07
PHP
viktorross, 2020-02-27 17:53:07

How to import via php record from one database to another?

Hello, tell me please, I want to call a function by pressing a button that would take a record of a certain table from the database and write this record to another database unchanged, how to implement this?

function call i will use like this

if(isset($_GET['add_new_post'])) {
  $usr->addNewPost($crt_usr);
  header("Location: post.php");
  exit(0);
}


function add_new_post($id) {
global $db;

//какой-то запрос в первую базу
$sql=$db-> ....

//подключение ко второй базе
$link = mysqli_connect('localhost', 'baza', 'password', 'table');

$sql_x=$db-> ....

mysqli_close($link);
}


And I have no idea what to do next.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanatPHP, 2020-02-27
@FanatPHP

See in any tutorial how to make INSERT queries in PHP.
And do as it says.

I
Ivan Kolotilkyn, 2020-02-27
@asurahan

try to file all this with an ORM library, for example, from https://redbeanphp.com/index.php
ORM itself will parse what fields are in the source table and create or add them to the final table.
Your question is certainly not an easy one, so it is unlikely that anyone here will write a whole application for you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question