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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:39:53+00:00 2026-05-20T22:39:53+00:00

I am trying to create an app which displays search results for a query

  • 0

I am trying to create an app which displays search results for a query as the user is typing similar to Google Instant. It doesn’t need to be under the search box like Instant but the idea is that relevant choices for a query appear as the user types.

Is there a way for me to use something similar?

Thanks

  • 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-20T22:39:54+00:00Added an answer on May 20, 2026 at 10:39 pm

    Here’s how I would solve the problem, using PHP and JavaScript.

    You will first need to set up a server side resource to serve search results, ideally in json.

    If you want to do this the right way, see this excellent tutorial on creating a REST API with PHP (it sounds like that’s the server side technology you’re using).

    If you want to hack something together quickly that may not be as robust, here’s how:

    First, create a php file at a given location, let’s say /api/search/search.php

    It should look something like this:

    <?php
        // connect to mysql
    
        if($_GET['q']) {
            $q = $_GET['q'];
    
            echo json_encode(getResults($q));
        } else {
            echo "No results";
        }
    
        function getResults ($q) {
            $sql = "SELECT * FROM whatever WHERE whichever LIKE '%'+"+$q+"+'%'"
    
            //mysql_fetch_results ...
    
            // loop through returned result set, create an associative array of results
    
            // i.e. $results = array("items" => array ( array ("link" => "#", "title" ="title"), array ("link" => "#", "title" ="title"), array ("link" => "#", "title" ="title") ))
    
            return $results;
        }
    
    ?>
    

    This will return json formatted results when you do a GET request to /api/search/search.php?q=Your query here

    You will need some client side code to party with the server. The basic approach is to set up an input box and every time the value changes, use jQuery’s AJAX methods ($.getJSON would work nicely here, but you could also use $.GET or $.AJAX), to send a request with the q parameter equal to the user’s query. You then attach a callback function that runs when the request is complete that parses the results and outputs them on the page. Some sample below.

    $(document).ready(function () {
        // This is your datasource url. Change this to be the resource you want
        var url = "https://www.googleapis.com/customsearch/v1?key=INSERT-YOUR-KEY&cx=013036536707430787589:_pqjad5hr1a&alt=json";
    
        // Attach a function to the keypress event for the input #q
        $("q").keypress(function () {
    
            // Get the value of the input
            var q = $(this).val();
    
            // Append the query to the end of the url
            url += "&q=" + q;
    
            // Make an ajax request to the api, and bind a function as a callback for when the request is complete
            $.getJSON(url, function (response) {
    
                // Store the items object. These are your results
                var results = response.items;
    
                var resultList = $(buildList(results));
    
                $("#results").empty().append(resultList);
            });
    
            function buildList (results) {
                // Initialize a string to hold the html formatted results
                var htmlStr = "<ul>";
    
                results.each(function () {
    
                    var result = $(this);
    
                    // Append the result's properties to your html
                    htmlStr += "<li><a href='"+result.link+"'>";
                    htmlStr += result.title;
                    htmlStr += "</a></li>";
    
                });
    
                htmlStr += "</ul>";
    
                return htmlStr;
            }
        });
    });
    

    Here’s the markup:

    <input id="q" type="text" />
    <div id="results"></div>
    

    Good luck

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

Sidebar

Related Questions

I am trying to create an app which has the ability to view calendar
I am trying to create an app which uses a combination of jQuery templates
I'm trying to create an app which plays videos from a file using AVFoundation
I am trying to create an android app which will show multiple web urls
I'm trying to create an iphone app which grabs a JSON string, parses it
I am trying to create an App which takes the GPS co-ordinates of my
I'm trying to create a raw folder for my android app which will hold
I'm trying to provide an in-app Activity which displays thumbnails of photos in the
I am trying to create an app on android which makes users login in
I'm trying to create an app for Android that simply sends a command to

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.