Jump to content

entering id numbers into multiple tables


dmblesley

Recommended Posts

[code]
<?php
$query = "INSERT INTO table_1 (information) VALUES (other information)";
mysql_query($query)or die ('Error in query: $query. ' . mysql_error());

$idvalue = mysql_insert_id(); // the id of the last insert statement

$query1 = "INSERT INTO table_2(id_from_table1) VALUES ('$idvalue')"; //or UPDATE if the row is already there
mysql_query($query)or die ('Error in query: $query. ' . mysql_error());
?>
[/code]

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.