title: jquery ui autocomplete html form multiple input type and mysql
body: <p>I have a form with multiple input type.<br>
  I know how retrieve data from mysql database using an external source file (in my case it's PHP) but i don't know how to associate each column from mysql database to the right input field without repeating the code??<br>
  Please help me..   </p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form id="form" class="form" autocomplete="off" action="" method="POST"&gt;
      &lt;input class="auto" type="text" name="client" value="" id="client" placeholder="Client Name" autofocus /&gt;
      &lt;input class="auto" type="text" name="firstname" value="" id="firstname" placeholder="First Name" /&gt;
      &lt;input class="auto" type="text" name="lastname" value="" id="lastname" placeholder="Last Name" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>PHP:  </p>
  
  <pre><code>&lt;?php
  header('Content-Type: text/html; charset=utf-8'); 
  
  include_once '../connection.php';
  
  if (isset($_GET['term'])) {
      $return_arr = [];
  
      $query = ("SELECT DISTINCT client, FirstName, LastName
                 FROM office_adv 
                 WHERE client LIKE :term OR
                       FirstName LIKE :term OR
                       LastName LIKE :term");
  
      $sth = $db-&gt;prepare($query);
      $sth-&gt;execute(array('term' =&gt; '%' .$_GET['term'] . '%'));
  
      while ($row = $sth-&gt;fetch(PDO::FETCH_ASSOC)) {
          $return_arr[] = $row['client'];
          $return_arr[] = $row['FirstName'];
          $return_arr[] = $row['LastName'];
      }
      echo json_encode($return_arr, JSON_UNESCAPED_UNICODE);
  }
  ?&gt;  
  </code></pre>
  
  <p>JQUERY:  </p>
  
  <pre><code>$(function() {
      $(".auto").autocomplete({
          source: "php/clientFind.php",
          minLength: 2,
          autoFocus: true
      });
  });  
  </code></pre>
  
  <p>thanks again !!  </p>