I want to connect 2 tables in my query to show results.
I have lastname, firstname etc in the first table.
In the second table I have training, date...  
I also have in the second table an ID reference that links lastname and firstname to training and date.
So whenever I create a training record into the database it uses the same ID for the same person.
I want to be able to connect both tables in my query and show results if I search for lastname.
It will also list all the training that they have completed if I click there name in the search that came up.
I am very new at MySQL database.
I am using phpmyadmin for MySQL and running a localhost database for testing purposes...
I currently can search a single table and bring up results, but I cannot figure out the union to link them and have the names list as a link to show there training. and having it keep there name at the top for a printout... here is the code I am using that I got from a tutorial.
    <form>
  <div align="right">
    <input type="button" value="Print Results" onClick="myprint()">
  </div>
</form>
<?php
// TAKE THE INFORMATION FROM FORM.
$search = $_GET['search'];
// IF THERE IS NOT A KEYWORD GIVE AN ERROR
if (!$search) 
echo "You didn't enter a keyword";
else
{
  echo "<td>You searched for: <strong>$search </strong></td>";
  mysql_connect('localhost','loginid','password');
  mysql_select_db('trainingrecords');  
  $id=@$_GET['id'];
  //QUERY IS THE CODE WHICH WILL MAKE THE SEARCH IN YOUR DATABASE.
  //I WROTE AN EXPLANATION ABOUT IT AFTER THE CODE.  
  $query="SELECT * FROM username 
          WHERE MATCH( lastname, firstname, location, created) 
          AGAINST('%$search%' IN BOOLEAN MODE)";
  $result1 = MySQL_query($query);  
  if(!$result1) {  
    echo MySQL_error()."<br>$query<br>";
  }  
  if (MySQL_num_rows($result1) > 0) {
    echo "<table width='750' align='center' border='1' 
           cellspacing='2' cellpadding='2'>";
    while($result2 = MySQL_fetch_array($result1)) {
      //A short description from category.
      $description = $result2['location'];
      $searchPosition = strpos($description, $search);
      $shortDescription = substr($description, $searchPosition, 150);
      echo "<td><strong>{$result2['lastname']} 
            {$result2['firstname']}</td></strong><td>
            $shortDescription</td><td>{$result2['created']}</td><tr/>";
    }
    echo "</table>";
  } else {
    echo "No Results were found in this category.<br>";
  } 
  echo "<br>";
}
?>
 
     
     
     
     
     
     
    