jquery autocomplete in background of input text box using -'php,javascript,jquery,html,css'

jquery autocomplete in background of input text box  using -'php,javascript,jquery,html,css'

I have a jQuery text box autocomplete script which uses a PHP script to query a MySQL database. Currently, a result is displayed under the text box however I want it to appear as if it is faded out in the text box. How can I do something like this? An example of this is on the Google Instant search box.

My current web page code is:

<script type='text/javascript'>
function lookup(a)
        $.post("suggest.php", { query: ""+a+"" }, function(b)

<input type='text' id='query' onkeyup='lookup(this.value);'>
<div id='suggestions'></div>

And my PHP code is:

$database = new mysqli('localhost', 'username', 'password', 'database');

    $query = $database->real_escape_string($_POST['query']);

    if(strlen($query) > 0)
        $suggestions = $database->query("SELECT name, value FROM search WHERE name LIKE '%" . $query . "%' ORDER BY value DESC LIMIT 1");

            while($result = $suggestions->fetch_object())
                echo '' . $result->name. '';


asked Sep 7, 2015 by rajesh
0 votes

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.