title: how to pre populate fields based on search results of data base
body: <p>I am new to stack overflow and really appreciate all the help. I currently have a database with basic columns, name id company etc. I created a search query that shifts through this list based on firstname, lastname, or timestamp date. I was able to print the results on the query page  of the search but want this to pre populate on the same form page as a new entry. i was able to link from the query page to the form page but am not sure how to populate these results on the form page. </p>
  
  <p>my current query page prints as the following : </p>
  
  <pre><code>       &lt;!DOCTYPE html&gt;
       &lt;html&gt;
         &lt;head&gt; 
       &lt;title&gt; 
  
        &lt;/title&gt;
         &lt;/head&gt;
      &lt;body&gt;
  
        &lt;div id="container" style="width:750px;background-color:#FFFE8D;margin-left: 250px"&gt;
  
      &lt;div id="Back" style="float:left; background-color:#FFFE8D;"&gt;
      &lt;form action="http://localhost/contractor/existingcontractorpage3.php"&gt;
      &lt;input type="submit" value="Back"&gt;
      &lt;/form&gt;
      &lt;/div&gt;
      &lt;div id="Is this the Contractor?" style="float:right; background-color:#FFFE8D;"&gt;
      &lt;form action="http://localhost/contractor/redirectcontractorpage.php"&gt;
      &lt;input type="submit" value="Next"&gt;
      &lt;/form&gt;
      &lt;/div&gt;
  
  &lt;div id="info" style="width:750px;height:95px; text-align: center"&gt;
  
  &lt;h3&gt; If this is the contractor, please move on to the next page using the corresponding button above. &lt;/h3&gt;
  &lt;h3&gt; Please enter the exact information on the next page. &lt;/h3&gt; 
  &lt;/div&gt;
  
  &lt;div id="results" style="width:750px;height:225px; text-align: center"&gt;
  
   &lt;?php
  
    $host = "localhost"; //server
   $db = ""; //database name
   $user = ""; //databases user name
   $pwd = ""; //password
   mysql_connect($host, $user, $pwd) or die(mysql_error());
   mysql_select_db($db) or die(mysql_error()); 
  
  $searchTerm = trim($_GET['searchname']);
  
    // Check if $searchTerm is empty
  if($searchTerm == "")
      {
          echo "Enter name you are searching for.";
          exit();
           } 
         else 
           { 
        $sql = "SELECT * FROM contractor WHERE CONCAT(FIRSTNAME,' ',LASTNAME,' ', ARRIVAL) like                                                             '%$searchTerm%'";  
                  $query = mysql_query($sql);
                      $count=mysql_num_rows($query);
  
          if(($count)&gt;=1)
      {
      $output = "";
      while($row = mysql_fetch_array($query))
      {
          $output .= "First Name: " . $row['FIRSTNAME'] . "&lt;br /&gt;";
          $output .= "Last Name: " . $row['LASTNAME'] . "&lt;br /&gt;";
          $output .= "Arrival: " . $row['ARRIVAL'] . "&lt;br /&gt;";
       }
          echo $output;
        }
          else
         echo "There was no matching record for the name " . $searchTerm;
  }
    ?&gt;
  
  &lt;/div&gt;
  &lt;br&gt; &lt;/br&gt;
  &lt;br&gt; &lt;/br&gt;  
        &lt;/body&gt;
       &lt;/html&gt;
  </code></pre>
  
  <p>Now ideally i would want the results to pop up here, and if possibly have a radio button to the right of each result( if there is ever more than one) to select and continue to the form page to pre populate each field. the form page is simply like this: </p>
  
  <pre><code>          &lt;form action="insert_submit.php" method="post"&gt;
  
        First Name: &lt;input type = "text" name="FIRSTNAME" id="FIRSTNAME" /&gt;
  
   &lt;br&gt;
   &lt;/br&gt;
  
   Last Name: &lt;input type = "text" name="LASTNAME" id="LASTNAME"/&gt;
  
   &lt;br&gt;
   &lt;/br&gt;
  
   Purpose: &lt;input type = "text" name="PURPOSE" id="PURPOSE"/&gt;
  
  &lt;br&gt;
  &lt;/br&gt;
  Company: &lt;input type = "text" name="COMPANY" id="COMPANY" /&gt;
  
  &lt;br&gt;
  &lt;/br&gt;
  
  Who here to see: &lt;input type = "text" name="WHOHERETOSEE" id="WHOHERETOSEE"/&gt;
  
  &lt;br&gt;
  &lt;/br&gt;
  
  &lt;input type="submit" value="Submit"&gt;
  
  &lt;br&gt;
  &lt;/br&gt;
  
  &lt;/form&gt; 
  </code></pre>
  
  <p>thanks so much! hope to hear back soon as this is my last straw on my project. </p>