title: PHP MySQL autocomplete
body: <p>I have an auto complete search field which as the user types a name, th results are shown in the dropdown.</p>
  
  <p>This all works fine, and shows the data as it should.</p>
  
  <p>I am waiting to make each result a link however, so when the results are shown the user can click on the correct name and it will take them to their profile.</p>
  
  <p>See script below:</p>
  
  <pre><code>&lt;input type='text' id=employees class='form-control' size="80" placeholder="Search Employees by first or last name"&gt;
  </code></pre>
  
  <p><strong>search.php</strong></p>
  
  <pre><code>$searchTerm = $_GET['term'];
  
      $sql = mysql_query ("SELECT name_first, employee_id, unique_id, name_last FROM hr_employees WHERE name_first LIKE '{$searchTerm}%' OR name_first LIKE '{$searchTerm}%' OR employee_id LIKE '{$searchTerm}%'");
      $array = array();
      while ($row = mysql_fetch_array($sql)) {
          $array[] = array (
  
              'value' =&gt; $row['name_first'].' '.$row['name_last'].' ('.$row['employee_id'].')',
  
          );
      }
      //RETURN JSON ARRAY
      echo json_encode ($array);
  </code></pre>
  
  <p>Upon selecting the correct user, I would like the user to de directed to page.php?id=$employee_id</p>
  
  <p>Is this possible?</p>
  
  <p><strong>JavaScript</strong></p>
  
  <pre><code>&lt;script src="//code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;
  &lt;script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p><strong>JavaScript</strong></p>
  
  <pre><code>&lt;script&gt;
  $(function() {
  $( "#employees" ).autocomplete({
  source: 'search.php'
  });
  });
  &lt;/script&gt;
  </code></pre>