title: How to use mysql_insert_id with a junction table
body: <p>I have a form and three tables: <code>customer</code>, <code>phone_number</code>, and <code>junction</code> (to create a many-to-many relationship).</p>
  
  <p>I need the form to populate all three tables using the newly created auto-incremented ids from the <code>customer</code> and <code>phone number</code> tables to populate the <code>customer_id</code> and <code>phone_id</code> columns in the <code>junction</code> table.</p>
  
  <p>I came up with the following, which will insert the newly created id from the <code>customer</code> table into the <code>junction</code> table, but I can't figure out how to get the phone number to do the same thing.</p>
  
  <pre class="lang-php prettyprint-override"><code>$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());
  </code></pre>