hi all i'm trying to add a 'search by keyword' text field to a search page. the 'search by keyword' search field should allow users to enter a comma delimited string containing a list of keywords to search the database for.
on the search_results page, what happens is: -i use explode() to break the comma-delimited string down into array elements, and count() to count the number of array elements -then i use a for loop to cycle through the list of array elements and run a sql query to search through a table for any matches to a particular array element. the for loop looks like //for loop that cycles through elements in an array, and searching through a mys ql table for matches for($j=0; $j<$count_elements; $j++) {$sql.="and columnname like '%keywords[$j]%' or columnname2 like '%keywords[$j]' or columnname3 like '%keywords[$j]%'...'";} i think this is technically working, since it's not giving me any errors, however it basically slows down searches to the point of unusability. i'm not entirely sure if my methodology in this case is the most efficient way to accomplish this particular task. if anyone can give any pointers, i'd appreciate it. thanks redmond -- FreeBSD 5.1-RELEASE-p10 FreeBSD 5.1-RELEASE-p10 #0: Fri Oct 3 21:30:51 CDT 2003 10:30AM up 7 days, 2:11, 5 users, load averages: 1.01, 1.02, 1.00 Speak softly and own a big, mean Doberman. -- Dave Millman
pgp00000.pgp
Description: PGP signature