PDA

View Full Version : insert data into more tables


adique_7
05-18-02, 05:04
hi there.......


now i had coding how to insert data into one table only........
so, how can i insert data into more tables? i know by detect which one primary and foreign key?

but how it works?

KNSPAA
05-21-02, 08:32
$sql="INSERT INTO TABLE1 " .....
if (mysql_query($sql,$dbcnx)){
$sql="INSERT INTO TABLE2 " .....
if (mysql_query($sql,$dbcnx)){
else {
echo ("Error in insert");
}
}
else {
echo ("Error in insert");
}

and if you need to know the autoincrement value for the next insert
$id=mysql_insert_id();