title: MYSQL, PHP & JQuery AutoComplete. Can you use it with a JOIN on multiple tables?
body: <p>Okay so I'm getting to the next stage with JQuery and I've used AutoComplete a few times with success but only using 1 table from MYSQL. Now I'm using it and trying to do a JOIN query with it. The MYSQL query works fine when I change <code>LIKE :term</code> to <code>= 1</code> (A customer number for example.) in MYSQL but when I try the Query below I dont get anything, not errors just nothing. Any suggestions?</p>
  
  <p>::: THIS IS THE SEARCH PAGE :::</p>
  
  <pre><code>&lt;?php require '../_includes/jq.inc.php';?&gt;
  &lt;link href="../_stylesheets/UPDATE.Customer.css" rel="stylesheet" type="text/css"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript"&gt;
  $(function() {
      $('#CustomersCustomer_ID').val("");
      $('#CustomersCompanyName').val("");
      $('#CustomerDetailsDiscount').val("");
      $('#CustomerNotesCustNotes').val("");
             $("#searchterm").autocomplete({
                  source: "UPDATE.Customer.SEARCH.QUERYTEST.php",
                  minLength: 1,
                  select: function(event, ui) {
                          $('#CustomersCustomer_ID').val(ui.item.CustomersCustomer_ID);
                          $('#CustomersCompanyName').val(ui.item.CustomersCompanyName);
                          $('#CustomerDetailsDiscount').val(ui.item.CustomerDetailsDiscount);
                          $('#CustomerNotesCustNotes').val(ui.item.CustomerNotesCustNotes);
                  }
              });
       });
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form action="&lt;?php echo $PHP_SELF;?&gt;"  method="post"&gt;
  SEARCH:&lt;p class="ui-widget"&gt;
  &lt;input type="text" id="searchterm" size="60" onClick="this.form.reset()"/&gt;
  &lt;/form&gt;
  &lt;form&gt;
    CustomersCustomer_ID&lt;br&gt;
    &lt;input name="CustomersCustomer_ID" type="text" id="CustomersCustomer_ID" size="10"&gt;
    &lt;br&gt;
    CustomersCompanyName&lt;br&gt;
    &lt;input name="CustomersCompanyName" type="text" id="CustomersCompanyName" size="20"&gt;
    &lt;br&gt;
    CustomerNotesCustNotes&lt;br&gt;
    &lt;textarea name="CustomerNotesCustNotes" id="CustomerNotesCustNotes" cols="20" rows="3"&gt;&lt;/textarea&gt;
   &lt;br&gt;
    CustomerDetailsDiscount&lt;br&gt;
    &lt;input name="CustomerDetailsDiscount" type="text" id="CustomerDetailsDiscount" size="5"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;  
  </code></pre>
  
  <p>THIS IS THE BACKEND QUERY PAGE
  // LEFT OUT THE CONNECTION INFO
      
  
  <pre><code>if ($conn)
  {
  $ac_term = "%".$_GET['term']."%";
  $query = "SELECT
      Customers.Customer_ID,
      Customers.CompanyName,
      CustomerDetails.Discount,
      CustomerNotes.CustNotes,
      CONCAT_WS(' ', Customers.Customer_ID, Customers.CompanyName, CustomerDetails.Discount, CustomerNotes.CustNotes) AS DisplayName
  FROM Customers
  JOIN CustomerDetails USING (`Customer_ID`)
  JOIN CustomerNotes USING (`Customer_ID`)
  WHERE `Customer_ID` LIKE :term
      OR Customers.CompanyName LIKE :term
      OR CustomerDetails.Discount LIKE :term
      OR CustomerNotes.CustNotes LIKE :term
      ";
  
      $result = $conn-&gt;prepare($query);
      $result-&gt;bindValue(":term",$ac_term);
      $result-&gt;execute(); 
  
      while ($row = $result-&gt;fetch(PDO::FETCH_ASSOC)) {
  
          $row_array['value'] = $row['DisplayName'];
  
          $row_array['CustomersCustomer_ID'] = $row['Customers.Customer_ID'];
          $row_array['CustomersCompanyName'] = $row['Customers.CompanyName'];
          $row_array['CustomerDetailsDiscount'] = $row['CustomerDetails.Discount'];       
          $row_array['CustomerNotesCustNotes'] = $row['CustomerNotes.CustNotes'];
  
          array_push($return_arr,$row_array);
      }
  
  }
  $conn = null;
  echo json_encode($return_arr);
  ?&gt;
  </code></pre>