Here just a little example how you can do this:

// index.htm
...
<script>
$("#autocomplete").autocomplete("search.php");
</script>
...

// search.php
<?php
mysql_connect("localhost", "user", "pass");
mysql_select_db("mySearchTable");

$query = mysql_query("SELECT * FROM T_Search WHERE name LIKE '" .
$_REQUEST["q"] . "%'");

while ($row = mysql_fetch_assoc($query)) {
    echo $row["name"] . "|";
    echo $row["firstname"] . "\n";
}
?>

that's all.


On 24 Sep., 09:53, "Jörn Zaefferer" <[EMAIL PROTECTED]>
wrote:
> You can't query a MySQL database from JavaScript. There has to be some
> serverside script to execute a query and return the results. Thats
> what search.php is supposed to do.
>
> Jörn
>
> On Tue, Sep 23, 2008 at 8:51 PM, allan2008 <[EMAIL PROTECTED]> wrote:
>
> > Hello.
>
> > I'm trying to figure out the bassistance jQuery plugin: Autocomplete.
> > From what I can gather if I want to get results remotely they must be
> > held in an external php file (ie. search.phps). Is it possible for the
> > plugin to get results directly from a mysql table? If so how can I get
> > it to search through the table? Thanks.

Reply via email to