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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.