Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Insert into 2 tables.

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Insert into 2 tables.

Postby Erick020 » Sat Jan 04, 2003 4:06 am

I need to insert some data into 2 tables at the same time :

$q="insert into table_A (Data1, Data2) values ('$Data1', '$Data2')";

$q="insert into table_B (Data2, Data3) values ('$Data2', '$Data3)";

What should be the right querry ?
The same question but for DELETE.

Thanks for your help,
Erick.
Erick020
New php-forum User
New php-forum User
 
Posts: 13
Joined: Thu Dec 26, 2002 6:20 am

Postby Joan Garnet » Sat Jan 04, 2003 6:46 am

Try this one -->
Code: Select all
mysql_select_db($database,$connection);
////////////////////////////////////////////////////////
$sql_one = "insert into table_A (Data1, Data2) values ('$Data1', '$Data2')";
$sql_two = "insert into table_B (Data2, Data3) values ('$Data2', '$Data3)";
////////////////////////////////////////////////////////
$result_one=mysql_query($sql_one , $connection);
$result_two=mysql_query($sql_two , $connection);


bye!
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 5 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron