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 8649927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:41:00+00:00 2026-06-12T13:41:00+00:00

Hope to find an answer. I build an web-app in PHP where I have

  • 0

Hope to find an answer.

I build an web-app in PHP where I have a list of records and some search fields.
One of the search fields is “customernumber”.
Customernumbers are saved in the local database (MySQL). If I search on an customernumber, it gives me the according result-row of the database => logic.

Now I want to build an extention for this search field with jQuery UI Autocomplete.

What I want to do:

I want the user to be abel to search on customerNAME in the searchfield “customernumber” and Autocomplete wil give the correct customernumber into the value.

The customername is saved in an external ODBC database also with the customernumber.

What I have done already:

I’ve tried to fetch all the names and numbers from the external ODBC database ans I got a list like this:

customername: somename1 
customernumber: number1

customername: somename2
customernumber: number2

customername: somename3 
customernumber: number3

... and so on

If I do autocomplete with an ajax call too this list, it doesn’t work at all.

Can someone PLEASE help me!? After several houwers of search, I couldn’t find the answer on the internet or anything close to it.

I would be really greatfull!
Thanks!

My Example of what I got so far:

jQuery script:

<script
    $(function() {
        function log( message ) {
            $( "<div/>" ).text( message ).prependTo( "#log" );
            $( "#log" ).scrollTop( 0 );
        }

        $( "#customer" ).autocomplete({
            source: function( request, response ) {
                $.ajax({
                    url: "customers.php",
                    dataType: "json",
                    success: function( data ) {
                        response( function( item ) {
                            return {
                                label: item.customername,
                                value: item.customernumber
                            }
                        });
                    }
                });
            },
            minLength: 3,
            select: function( event, ui ) {
                log( ui.item ?
                    "Selected: " + ui.item.label :
                    "Nothing selected, input was " + this.value);
            }
        });
    });
</script>

Input HTML:

<div class="ui-widget">
    <label for="customer">Search</label>
    <input id="customer" />
</div>

SQL Query in customers.php

$connection = odbc_connect('host', 'username', 'password') 
              or die('Connection failed!');

$sql = "SELECT 'customername', 'customernumber' FROM 'database.table'";

$results = odbc_exec($connection, $sql);

while($myRow = odbc_fetch_array($results)){
    $rows[] = $myRow;
};

foreach($rows as $row) {
    foreach($row as $key => $value) {
        echo $key . ': '. $value . '<br/>';
    }
};

To be clear

I type into the searchbox the customerNAME,
and I want to retrieve the customerNUMBER as the value.

  • 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-06-12T13:41:02+00:00Added an answer on June 12, 2026 at 1:41 pm

    You have to pass data back in the proper format.

     while($r = odbc_fetch_array($results))
        $rows[] = array("label" => $r[0], "value" => $r[1]);    
     echo json_encode($rows);
    
     $("#search").autocomplete({  
            //define callback to format results  
            source: function(request, response){  
                //pass request to server  
                $.getJSON("query.php?term=" + request.term, function(data) {  
                   response(data);
                });  
            });  
        });
    

    See jQuery UI documentation for more options.

    EDIT
    Issues with your current solution

    • odbc_fetch_array might return values without column names on some RDBS’s (use print_r to debug)

      name number
      Bob 123

    becomes

    Array
        (
            [0] => "Bob"
            [1] => 123
        )
    
    • JSON output is not even valid (use firebug to debug), currently output for our example would be:

      0:”Bob”
      1:123

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have search all over the web, but unable to find an answer, so
I didn't find an answer on the net and i hope this question have
I have a simple question and I hope I can find answer here! Can
Total PHP Noob and I couldn't find an answer to this specific problem. Hope
I'm newbie with Nhibernate. Hope I can find the answer here. This is my
Hope find a guru's help to figure out the next problem. I have two
I'm struggling with a RegEx, and I hope to find some guidance here. I
I hope I will find a help here. I have a quite complex MVC
I am a noob for the WPF. Hope i can find answer. For example,
I havn't been able to find the answer to this, and I hope theres

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.