Insert into 2 tables.

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
Erick020
New php-forum User
New php-forum User
Posts: 13
Joined: Thu Dec 26, 2002 6:20 am

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.

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

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!

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 6 guests