acctman Posted April 26, 2009 Share Posted April 26, 2009 i'm trying to setup an auto complete script this is an example of it pulling from a array. how can i pull from a database in real time? right now the GET request to the array is done in real time but would a db be more faster when i have about 1000+ cities ? <?php $q = strtolower($_GET["q"]); if (!$q) return; $items = array( "Great <em>Bittern</em>"=>"Botaurus stellaris", "Little <em>Grebe</em>"=>"Tachybaptus ruficollis", "Black-necked Grebe"=>"Podiceps nigricollis", "Little Bittern"=>"Ixobrychus minutus", "Black-crowned Night Heron"=>"Nycticorax nycticorax", "Purple Heron"=>"Ardea purpurea", "White Stork"=>"Ciconia ciconia", "Spoonbill"=>"Platalea leucorodia", "Red-crested Pochard"=>"Netta rufina", "Common Eider"=>"Somateria mollissima", "Red Kite"=>"Milvus milvus", "Solitary Sandpiper"=>"Tringa solitaria", "Heuglin's Gull"=>"Larus heuglini" ); foreach ($items as $key=>$value) { if (strpos(strtolower($key), $q) !== false) { echo "$key|$value\n"; } } ?> [code=php:0] Link to comment https://forums.phpfreaks.com/topic/155760-flat-file-array-or-mysql-db-for-auto-complete-script/ Share on other sites More sharing options...
coalgames Posted April 26, 2009 Share Posted April 26, 2009 Pulling from a database would require a lot of overhead processing the queries. You might want to make a automated script that pulls from the database and caches it into a script every 5 minutes or so. You would not want to use a database if you arent using a persistent connection. Link to comment https://forums.phpfreaks.com/topic/155760-flat-file-array-or-mysql-db-for-auto-complete-script/#findComment-819923 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.