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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:04:14+00:00 2026-06-18T02:04:14+00:00

Trying to get my live search to work ‘properly’. When I enter an ‘a’

  • 0

Trying to get my live search to work ‘properly’. When I enter an ‘a’ I get ‘aussie’ and ‘australian’ (not sure where these are coming from as they are not in my db) in a area below the box (like a drop down). I can select one of them and it populates the text box. The code suggested to me uses mysqli which I am not familiar with. When I add a typical SELECT statement I am use to I see the correct data (more or less) but it is not selectable. The reason I say more or less is an ‘a’ gives me ‘aussie’ and ‘australian’ like before (in a drop down). Adding a ‘n’ (i.e. searching for ‘an’) gives me list of all names in my database that contain the string in a DIV but not selectable.

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript"> 
        $(document).ready(function() {
            $("#faq_search_input").keyup(function() {
                var faq_search_input = $(this).val();
                var dataString = 'keyword='+ faq_search_input;

                if(faq_search_input.length>1) {
                    $.ajax({
                        type: "GET",
                        url: "ajax-search.php",
                        data: dataString,
                        success: function(server_response) {
                            document.getElementById("searchresultdata").style.display = "block";
                            $('#searchresultdata').html(server_response).show();
                        }
                    });
                } return false;
            });
        });
    </script>


</head>
<body>
    <div class="searchholder">
       <input  name="query" class="quicksearch" type="text" id="faq_search_input" />
       <div id="searchresultdata" class="searchresults" style="display:none;"> </div>
    </div>
</body>
</html>

ajax-search.php

<?php
    //you must define your database settings
    define("DB_HOST", "localhost");
    define("DB_USERNAME", "root");
    define("DB_PASSWORD", "");
    define("DB_NAME", "mydb");
    if(isset($_GET['keyword'])) {
        $search = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);
        if ($search->connect_errno) {
            echo "Failed to connect to MySQL: (" . $search->connect_errno . ") " .     $search->connect_error;
            $search->close();
        }
        $keyword =  trim($_GET['keyword']) ;

        //original statement
        //$query ="SELECT COLUMN_NAME FROM ".DB_NAME.".INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE '%".$keyword."%'";

        //my edited statement
        //$query ="SELECT name FROM ".DB_NAME.".INFORMATION_SCHEMA.COLUMNS WHERE name LIKE '%".$keyword."%'";

        //basic sql statement
        $query ="SELECT name FROM users WHERE name LIKE '%".$keyword."%'";

        $values = $search->query($query);
        if( $search->error ) exit( $search->error ); 

        if($values->num_rows != 0) {
            while($row = $values->fetch_assoc()) { 
                echo $row['name']."<br>";
            } 
        }
        else {
            echo 'No Results for :"'.$_GET['keyword'].'"';
        }
    }
?>

database contains a table of user data called users with a column called name.
Any thoughts?

  • 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-18T02:04:15+00:00Added an answer on June 18, 2026 at 2:04 am

    Used solution found in the tutorial here
    http://www.htmlblog.us/jquery-autocomplete

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

Sidebar

Related Questions

When trying to run the sample code here: http://www.nikhilk.net/Live-Search-REST-API.aspx I get: Error 52 The
I am trying to get John Resig's jQuery Live Search with Quicksilver Style to
I am trying get Struts 2 and Tiles to work and I am using
Trying to get a wildcard search to pick up on any text in org_name
Trying to get this expression to work, can someone look at it and tell
I'm trying to highlight the text that matches the query in a live search
I'm trying to get a background in a live wallpaper to behave like a
I am trying to make a live search combo box and everything is working
I'm trying to get a live progress indicator working on my php CLI app.
I'm trying to get the access token from the windows live connect api by

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.