...

View Full Version : autosuggest help.



dajohnson1s
03-07-2009, 10:14 AM
Hello,

I am wanting to add autosuggest to my application. I have a database that pulls names of buildings to show on google maps. I would like to add a building search feature.

I have seen a few jquery examples, is there a way to maybe pull the data from the database and store in some array or something similar?


Thanks

abduraooft
03-07-2009, 10:24 AM
http://www.w3schools.com/php/php_ajax_suggest.asp may help to start.

dajohnson1s
03-07-2009, 07:23 PM
abduraooft,

Thanks for the link,

This is what I am referring to:
My demo (http://wds.semo.edu/test/auto/autocomplete.php)

I have seen a few of these that have a response time that is almost instantaneous. So I am wondering if my delay is due the speed of the server.

I also have this jquery example:
jquery autocomplete (http://wds.semo.edu/test/sample.php)

The second (jquery) calls from an array/plugin.

Ok, I had found this on my work computer, this is what I would like to do http://www.simonwhatley.co.uk/examples/autocomplete/jquery/

and it pulls from this:


<?php
$q = strtolower($_GET["q"]);
if (!$q) return;
$items = array(
"1"=>"Algeria",
"2"=>"Argentina",
"3"=>"Australia",
//the rest are continued//
"96"=>"Vietnam",
"97"=>"West Africa",
"98"=>"Yemen",
"99"=>"Yugoslavia",
"100"=>"Zimbabwe"
);

foreach ($items as $key=>$value) {
if (strpos(strtolower($value), $q) !== false) {
echo "$value\n";
}
}


?>


Is there a way to query the database and build/store this array with the new data? Most of this will stay the same for the majority of the time, and seems wasteful to pull from the database each time. The plan is to make an admin panel or some other kind of backend to keep the data up to date. So I had figured I could have a function call or something to build this array.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum