...

View Full Version : backend php for autocomplete



mjl927
01-24-2008, 04:53 PM
I'm using the jquery autocomplete plugin found here....

http://www.dyve.net/jquery/?autocomplete

and I'm getting confused over how the backend PHP code needs to be programmed when the data comes from a mysql db.

If I follow the example provided at the site, I'm led to believe that I simply echo the array of items pulled from the DB. However, I get absolutely no results in my autocomplete field. My PHP works perfectly fine when I test it by itself so I know I'm retrieving the data correctly

Here's an example of my PHP script



<?php

include ("connect.php");

$q = strtolower($_GET["q"]);
if (!$q) return;

$arr=array();

$quer=mysql_query("SELECT * FROM owners where lname like '$q%' order by lname");
while($row = mysql_fetch_array($quer))
{
$arr[]=$row['lname'].', '.$row['fname'].'<br />';
}
foreach ($arr as $value)
{
echo $value;
}

mysql_close();

?>


Any insight is appreciated.

Thanks,

-Mike

mjl927
01-24-2008, 08:33 PM
Nevermind. I got it working.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum