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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:57:25+00:00 2026-05-13T11:57:25+00:00

Hello I am using autocomplete to allow users to search venues stored in a

  • 0

Hello I am using autocomplete to allow users to search venues stored in a MySQL database. The autocomplete plugin is currently listing the venues when the user begins typing and prints the selected venue using the result handler.

I would like to also print the address, phone number and website of the venue as well but I am not sure how to do this.

I have the autocomplete plugin running a php script to print out the venue names from the database. I am not sure how to retrieve the other fields in the database without displaying the autocomplete input field…

This is what I have so far:

JQuery

  $(document).ready(function(){
    $("#example").autocomplete("search.php", {width: 260, selectFirst: false}).result(function(event, data, formatted) {
    $("#result").html( !data ? "No match!" : "Selected: " + formatted);
    });

});

PHP

$search = $_GET['q'];
    $search = "%".$search."%";
    $result = mysql_query("SELECT club_name FROM clubs WHERE club_name LIKE '$search'") or die('Something is wrong');
        while($value = mysql_fetch_array($result)){
            $club = $value[club_name];
            echo "$club\n";
        }

The php above only select the club name because when I try to select more fields they display in the search results on the JQuery side.

I am new to JQuery so I am a little lost… Any suggestions?

  • 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-13T11:57:26+00:00Added an answer on May 13, 2026 at 11:57 am

    There are a few ways to do it, but this is the easiest:

    You want to return the data from the server like this. The first column should contain the value you want to retrieve in the end:

    title|address|phone|web
    title|address|phone|web
    title|address|phone|web 
    

    And then you want to use the formatItem and formatValue callback in your autocomplete function:

    $(document).ready(function(){
        $("#example").autocomplete("search.php", {
            width: 260, 
            selectFirst: false,
            formatItem: function(row){
              var ret = '<span class="title">' + row[0] + '</span><br />';
              ret += '<span class="address">' + row[1] + '</span> ';
              ret += '<span class="phone">' + row[2] + '</span> ';
              ret += '<span class="web">' + row[3] + '</span> ';
              return ret;
            },
            formatValue: function(row){
              return row[0]; // We only want the first value to be searched
            }
          }).result(function(event, data, formatted) {
            $("#result").html( !data ? "No match!" : "Selected: " + formatted);
          });
    });
    

    Also, your are not escaping the input from the user and as such have a nasty vunerability for SQL injection

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

Sidebar

Related Questions

Im currently using the JQuery UI extension for its search autocomplete. However, I need
Hello I'm using this star rating widget http://www.fyneworks.com/jquery/star-rating/ to add functionality for users to
Hello i'm trying to use autocomplete dropdownlist plugin that name is ufd. Anyway, I
Hello I'm using the fullcalendar jQuery plugin to create a calendar app. When I
Hello iam using wordpress and i need to set permission for a plugin folder
I am using the jquery autocomple plugin like this $( #city ).autocomplete({ source: function(
hello im using this code to do search <form action=arama.php method=get> <input type=text name=lol>
Im currently developing an webapplication that are going to have an Autocomplete search form,
Using jQuery autocomplete.. Want to replace hello in script below with javascript to identify
Hello i am using post_controller hooks to validate user whether logged in or not

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.