Jump to content

Inserting into two tables at same time


salimalisalim

Recommended Posts

Hi,

I have a form, while submitting this i need to store the values into two different tables in a database,Some values will store in a table and others will store in a another table. How can i write it's query ?

For Example,

$sql="INSERT INTO table1 (field1, field2, field3,field4)
VALUES
('$_POST[column1]','$_POST[column2]','$_POST[column3]','$_POST[column4]')";


$sql2="INSERT INTO table2 (field5, field6, field7,field8)
VALUES
('$_POST[column5]','$_POST[column6]','$_POST[column7]','$_POST[column8]')";



For me like this, Only one $sql values are only inserting, $sql2 values are not inserting.


Thanks in Advance

Link to comment
https://forums.phpfreaks.com/topic/286433-inserting-into-two-tables-at-same-time/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.