title: Problem with PHP/MySQL Insert
body: <p>How to insert data into two or more tables?</p>
  
  <p>Currently I am using this trick. (Let just assume that the syntax is correct)</p>
  
  <pre><code>$Sql1 = "insert into user";
  $Sql2 = "insert into files";
  $Sql3 = "insert into messages";
  
  query $Sql1
  query $$ql2
  query $Sql3
  </code></pre>
  
  <p>So I am using this and I need to optimize.</p>
  
  <p>Also, I think I need to use Foreign key? But I don't know how to do it on phpmyadmin.</p>
  
  <p>and lastly:</p>
  
  <p>This is all I want.</p>
  
  <p>To insert data on the "user" table and then automatically the table "messages" and "files"
  will have also an ID which is the same with the user.. That is why I use to 3 queries in my code.</p>
  
  <p>Please help me.</p>
  
  <p>Thanks in ADVANCE!</p>
  
  <p>myb</p>