Logic Question: PHP Search Array |
Logic Question: PHP Search Array |
masonh928 |
Apr 9 2017, 10:11 PM
Post
#1
|
Serious Coder Group: Members Posts: 253 Joined: 17-August 13 From: Indiana Member No.: 19,570 |
This seems a little bit elementary, but I would really like to lay this logic out for critique. Often times when people think of a search page, they think of searching a database, but I have a folder with a list of pages that have info on certain poultry breeds. I basically just need a search function that retrieves breed pages. I'm thinking of using AJAX for this just for ease of use, not sure yet... but anyways. I was thinking that since I only have about 40 breeds, I could make an array of all the titles and search based on the array. Any other ideas? Just wanted to see if this logic checks out.
~Thanks, Mason! |
CharlesEF |
Apr 10 2017, 01:53 AM
Post
#2
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Since your poultry information is not in a database why involve AJAX? Just make the array and code for client side processing. I mean, you still need javascript for AJAX use.
|
Christian J |
Apr 10 2017, 06:00 AM
Post
#3
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
|
masonh928 |
Apr 10 2017, 02:31 PM
Post
#4
|
Serious Coder Group: Members Posts: 253 Joined: 17-August 13 From: Indiana Member No.: 19,570 |
I didn't really think of that. Hmm... I just thought that perhaps an AJAX search was more convenient. I could possibly use something like this I found on PHP.net
CODE <?php $dir = "/your_folder_here/"; // Open a known directory, and proceed to read its contents if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if($file == $_POST['SEARCHBOX_INPUT']){ echo('<a href="'.$dir . $file.'">'. $file .'</a>'."\n"); } } closedir($dh); } } ?> Of course, I'd change it a bit. |
Christian J |
Apr 10 2017, 02:47 PM
Post
#5
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
If you're going to use a search script, you might use Ajax to give the user search suggestions (the way e.g. Google does).
|
Lo-Fi Version | Time is now: 25th April 2024 - 10:39 PM |