title: Search in MySQL foreign field
body: <p>I'm fairly new to PHP and MySQL.</p>
  
  <p>I have two tables as follows: </p>
  
  <pre><code>1.`users`: `id`//primary key
           : `name`//user's name
  
  2.`events`: `u_id`//index key and foreign field to users' id
            : `u_name`
  </code></pre>
  
  <p>A user will input an <code>id</code> in a form. That <code>id</code> will be searched in the <code>users</code> table and the relevant details will be taken and inserted in the <code>events</code> table.</p>
  
  <p>I've created the foreign fields and and till now I made a function that took <code>id</code> as a variable and returned details from the <code>users</code> tables as variables which I then inserted in the <code>events</code> table. But then, it meant using "a lot" of variables and I thought what was the use of foreign field. 
  I'm still learning PHP and don't know how to find and insert using FOREIGN fields from one table to another. I just know how to create foreign fields. Please help.</p>