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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:23:08+00:00 2026-06-08T09:23:08+00:00

So im trying to populate an auto-complete search form from my database. Here is

  • 0

So im trying to populate an auto-complete search form from my database. Here is my php code that creates an array

    $leaders= mysql_query("SELECT model_name,model_id FROM models
             ORDER by model_name DESC");

while($leader=mysql_fetch_array($leaders)){
  $model= $leader['model_name'];
$modelid= $leader['model_id'];
    $name[] = array('label'=> $model, 'value'=> $modelid);

    $count = $count + 1;


}
$fp = fopen('results.php', 'w');
fwrite($fp, json_encode($name));
fclose($fp);

My problem lies somewhere within the jquery auto complete, the search form just returns a huge list of all the products in my json without filtering when the user types. My ideal goal would be to assign the value to the end of a url. Ex. “http://www.example.com/” + value

$(function() {
  $("#search").autocomplete({
    source: function(request, response) {
      $.ajax({
        url: "results.php",
        dataType: "json",
        data: { q: request.term },
        success: function(data) {
          response($.map(data, function(value,key) {
            return { label:value.label , value: value.value }
          }));
        }
      });
    },
    minLength: 2
  });
});

Thanks for the help

  • 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-08T09:23:09+00:00Added an answer on June 8, 2026 at 9:23 am

    i think your query was worng. you must use like condition on your query

     mysql_query("SELECT model_name,model_id FROM models where model_name like '$_post[q]%'  ORDER by model_name DESC")
    

    to fetch the particular selected result

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

Sidebar

Related Questions

Hi i am trying to auto populate a 2d array based on user input.
I am trying to populate an array with a path to a file. <?php
Currently I'm trying to add on to the auto-complete module for jquery that is
I am trying to auto-populate a text field based on the value of another
I'm trying to auto-populate a drop down list based on a request parameter. I'm
I am trying populate H3 with the sum of column E for rows that
I am trying to populate an array with the text value of a json
I am trying to populate a spinner, but am getting an error. Here is
I'm trying to insert variables from an SQL result into a HTML form in
I am trying to get data from a specific column in a database table

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.