Re: Multiple word queries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Shiloh Madsen wrote:

say someone enters a search string of  "cat dog mouse rabbit" (without the
qoutes) into my search box. What I need for the results page to do is to
construct a query that will search through my keywords table for every
instance of ANY of those words. How would you suggest I handle this?

For that simple example, you can just explode the string on the space and create a WHERE clause entry for each word.

For example:

$words = explode(' ',$_GET['search_text']);
foreach($words as $word)
{ $query .= " AND column LIKE '%$word%' "; }

Gets more complicated the more you want to parse the search text and is dependant upon what database you're using.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux