How to insert data in two different tables of two different database in php

前端 未结 5 919
醉酒成梦
醉酒成梦 2021-01-21 09:35

I have to insert data in two different database\'s table. I have created database1 and table1 for database1, also i have created database2 and table2 for database2.

For

5条回答
  •  甜味超标
    2021-01-21 09:55

    Simply connect to 1 database, insert new row, disconnect, connect to the other database, insert row into that one and disconnect.

    Or you can use $connect1 and $connect2 to refer to each of them separately and do the insertion parallely.

    EDIT: Btw you can select the database with the 4'th parameter of mysql_connect, no need to use mysql_select_db

    And very important, you should write mysqli not mysql. Because mysql functions are not going to be supported for much longer.

提交回复
热议问题