title: how to UPDATE using mysql_insert_id() into different table?
body: <p>I am using mysql_insert_id() on the first page (test2.php) to insert the same id on other tables that is submitted from different forms. The id is inserted perfectly however, when i want to insert the data from other forms (e.g: test.php), the data cannot be updated, I have to inform before this i was using insert and it is not systematic because it will insert a new data with new id. As reference, below are my php codings for page test2.php and test.php: </p>
  
  <p><strong>test2.php</strong>:</p>
  
  <pre><code>&lt;?php
  session_start();
  include("auth.php");
  $link = mysql_connect('localhost', 'root', '');
  if (!$link) {
      die('Could not connect: ' . mysql_error());
  }
  mysql_select_db('tempahperalatan');
  
  
  if(isset($_POST['submit'])){
  
      $noID = $_POST['noID'];
      $pemohon = $_POST['pemohon'];
      $trkhMula = $_POST['trkhMula'];
      $trkhAkhir = $_POST['trkhAkhir'];
      $n_program = $_POST['n_program'];
      $lokasi = $_POST['lokasi'];
      $n_anjuran = $_POST['n_anjuran'];
      $catatan = $_POST['catatan'];
  
  mysql_query("INSERT INTO daftartempah (noID, pemohon, trkhMula, trkhAkhir, n_program, lokasi, n_anjuran, catatan) values ('$noID','$pemohon','$trkhMula','$trkhAkhir','$n_program','$lokasi','$n_anjuran','$catatan')");
  mysql_query("INSERT INTO pasystems (noID) values ('$noID')");
  mysql_query("INSERT INTO ict_1 (noID) values ('$noID')");
  mysql_query("INSERT INTO pejabat (noID) values ('$noID')");
  printf("Last inserted record has id %d\n", mysql_insert_id());
  }
  
  ?&gt;
  </code></pre>
  
  <p>For page test.php, there is an echo of variables is because I was testing whether it reads the variables, and surprisingly it reads because it appear at the top of the page of the data that I entered however, the noID does not appear and that means it does not fetch the same id from the previous page (test2.php) and I think that is the problem why my data was not updated. Can anyone help me about this problem because I'm a student studying web programming and some guidance would be so helpful, thank you in advance.  </p>
  
  <p><strong>test.php:</strong></p>
  
  <pre><code>&lt;?php
  session_start();
  include("auth.php");
  $link = mysql_connect('localhost', 'root', '');
  if (!$link) {
      die('Could not connect: ' . mysql_error());
  }
  mysql_select_db('tempahperalatan');
  
  
  if(isset($_POST['submit'])){
  
      $noID = $_POST['noID'];
      $microphones = $_POST['microphones'];
      $amplifiers = $_POST['amplifiers'];
      $loudspeakers = $_POST['loudspeakers'];
      $mixers = $_POST['mixers'];
      $catatan = $_POST['catatan'];
  
      ?&gt;
      &lt;p&gt;&lt;?php    echo $microphones;echo $amplifiers; echo $loudspeakers; echo $mixers; echo $catatan; echo $noID; ?&gt;&lt;/p&gt;
      &lt;?php
  
  mysql_query ("UPDATE pasystems SET microphones='$microphones', amplifiers='$amplifiers', loudspeakers='$loudspeakers', catatan='$catatan' WHERE noID = '$noID'");
  
  
  }
  </code></pre>
  
  <p>Please ask if my question is not clear for you to help me, I will try to help you understand my problem/question.</p>