Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6720795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:15:14+00:00 2026-05-26T09:15:14+00:00

Okay so I’m getting to the next stage with JQuery and I’ve used AutoComplete

  • 0

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 LIKE :term to = 1 (A customer number for example.) in MYSQL but when I try the Query below I dont get anything, not errors just nothing. Any suggestions?

::: THIS IS THE SEARCH PAGE :::

<?php require '../_includes/jq.inc.php';?>
<link href="../_stylesheets/UPDATE.Customer.css" rel="stylesheet" type="text/css">
<html>
<head>
<script type="text/javascript">
$(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);
                }
            });
     });
</script>
</head>
<body>
<form action="<?php echo $PHP_SELF;?>"  method="post">
SEARCH:<p class="ui-widget">
<input type="text" id="searchterm" size="60" onClick="this.form.reset()"/>
</form>
<form>
  CustomersCustomer_ID<br>
  <input name="CustomersCustomer_ID" type="text" id="CustomersCustomer_ID" size="10">
  <br>
  CustomersCompanyName<br>
  <input name="CustomersCompanyName" type="text" id="CustomersCompanyName" size="20">
  <br>
  CustomerNotesCustNotes<br>
  <textarea name="CustomerNotesCustNotes" id="CustomerNotesCustNotes" cols="20" rows="3"></textarea>
 <br>
  CustomerDetailsDiscount<br>
  <input name="CustomerDetailsDiscount" type="text" id="CustomerDetailsDiscount" size="5">
</form>
</body>
</html>  

THIS IS THE BACKEND QUERY PAGE
// LEFT OUT THE CONNECTION INFO

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->prepare($query);
    $result->bindValue(":term",$ac_term);
    $result->execute(); 

    while ($row = $result->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);
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:15:15+00:00Added an answer on May 26, 2026 at 9:15 am

    i think that the reason you don’t get any results is because that you have an error in your query (duplicate ‘Customer_ID’ field), try this one:

    $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 Customers.Customer_ID LIKE :term
        OR Customers.CompanyName LIKE :term
        OR CustomerDetails.Discount LIKE :term
        OR CustomerNotes.CustNotes LIKE :term
        ";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, so I've known about this for like 600 years now, but I've only
Okay im making a mobile application using jquery, and then im using phonegap to
Okay, so I've done a bit of research into using PHP to allow using
Okay, I feel like I should be able to do this, but I have
Okay, so I'm pretty new to xcode but I cannot find something specific to
Okay so im working on this php image upload system but for some reason
Okay, so this is a long long shot but here it goes... When IE
Okay, here's the rundown. I'm developing a video hosting site with PHP and jQuery
Okay, I have setup up a handler for a div click but for some
Okay, so the answer to my question might not be the problem but here's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.