I have a form and three tables: customer
, phone_number
, and junction
(to create a many-to-many relationship).
I need the form to populate all three tables using the newly created auto-incremented ids from the customer
and phone number
tables to populate the customer_id
and phone_id
columns in the junction
table.
I came up with the following, which will insert the newly created id from the customer
table into the junction
table, but I can't figure out how to get the phone number to do the same thing.
$query = "INSERT INTO customer (first_name, last_name) VALUES (%s, %s)",
GetSQLValueString($_POST['first_name'], "text"),
GetSQLValueString($_POST['last_name'], "text"));
$result = mysql_query();
$insertID = mysql_insert_id();
$query = "INSERT INTO junction (customer_id) VALUES ($insertID)";
mysql_select_db($database_hh, $hh);
$result = mysql_query($query, $hh) or die(mysql_error());