Hi,
I am having my first foray into the world of AJAX and Javascript and
have created an Autosuggest search page. However, I want to have a
submit button that will list all database entreies that match the
search query and I can't work out what the best way to do this! Would
it be using a input button and some kind of onClick fucntion? If so,
does anyone know what the onClick function would be in jQuery? Would I
need to create some new script for this? If anyone can give me any
guidance on this I will be eternally grateful. Here is the code:

<?php
$db = new mysqli('128.0.0.1', 'asad' ,'asad', 'asad');
        if(!$db) {
                echo 'ERROR: Could not connect to the database.';
        } else {
                if(isset($_POST['queryString'])) {
                        $queryString = 
$db->real_escape_string($_POST['queryString']);

                        if(strlen($queryString) >0) {

                                $query = $db->query("SELECT DISTINCT OrgType 
FROM Contacts WHERE
OrgType LIKE '$queryString%' LIMIT 10");
                                if($query) {

                                        while ($result = $query 
->fetch_object()) {

                                        echo '<li 
onClick="fill(\''.$result->OrgType.'\');">'.
$result->OrgType.'</li>';
                                }
                                } else {
                                        echo 'ERROR: There was a problem with 
the query.';
                                }
                        } else {
                        }
                } else {
                        echo 'There should be no direct access to this script!';
                }
        }
?>

Reply via email to