title: retrieve and display data, from table stored in database, into a form (using foreign key).
body: <p>I have two tables, these are shown below:</p>
  
  <p>Employee - (employee_ID, first_name, Last_name, Address, ETC)
  Training - (training_ID, Employee_ID, First_name, Last_name, Training)</p>
  
  <p>Employee ID is foreign key in training table.</p>
  
  <p>I have a form for the training table, which is meant to be used by someone who will enter which employee needs which training.</p>
  
  <p>Is there anyway on my training form, I can have a drop down box for the employee field which will automatically update the first name and last name for that employee ID?</p>
  
  <p>OR is there just anyway I can have my form so that the employee ID is always with the right first name and last name.</p>
  
  <p>here is my form (html) and php code to submit it to database.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;link type="text/css" rel="stylesheet" href="style.css"/&gt;
  &lt;title&gt;Training&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;div id="content"&gt;  
  &lt;h1 align="center"&gt;Add Training&lt;/h1&gt;
  
  &lt;form action="inserttraining.php" method="post"&gt;
  &lt;div&gt;
  &lt;p&gt;Training ID: &lt;input type="text" name="Training_ID"&gt;&lt;/p&gt;
  &lt;p&gt;Employee ID: &lt;input type="text" name="Employee_ID"&gt;&lt;/p&gt;
  &lt;p&gt;First name: &lt;input type="text" name="First_name"&gt;&lt;/p&gt;
  &lt;p&gt;Last name: &lt;input type="text" name="Last_name"&gt;&lt;/p&gt;
  &lt;p&gt;
  Training required?
  &lt;select name="Training"&gt;
  &lt;option value=""&gt;Select...&lt;/option&gt;
  &lt;option value="Customer Service"&gt;Customer Service&lt;/option&gt;
  &lt;option value="Bailer"&gt;Bailer&lt;/option&gt;
  &lt;option value="Reception"&gt;Reception&lt;/option&gt;
  &lt;option value="Fish &amp; meat counters"&gt;Fish &amp; meat counters&lt;/option&gt;
    &lt;option value="Cheese counters"&gt;Cheese counters&lt;/option&gt;
  &lt;/select&gt;
  &lt;/p&gt;
  &lt;input type="submit"&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and php code:</p>
  
  <pre><code>&lt;?php
  $con = mysql_connect("localhost","root","");
  if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
  
  mysql_select_db("hrmwaitrose", $con);
  
  $sql="INSERT INTO training (Training_ID, Employee_ID, First_name, Last_name, Training)
  VALUES
    ('$_POST[Training_ID]','$_POST[Employee_ID]','$_POST[First_name]','$_POST[Last_name]','$_POST[Training]')";
  
  
  if (!mysql_query($sql,$con))
    {
    die('Error: ' . mysql_error());
    }
  echo "1 record added";
  
  mysql_close($con);
  ?&gt;
  </code></pre>
  
  <p>Thanks in advance and sorry if my code doesnt display well.</p>