Re: Creating a Search field

From: Date: Fri, 10 Oct 2003 01:53:08 +0000
Subject: Re: Creating a Search field
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-165683@lists.php.net to get a copy of this message
I need to create a feature that allows users to enter certain words that can be searched ie search = 'red lion' this would return all data found with the words red and lion.
If you're using MySQL 4.0, you can take advantage of its FULL TEXT searching (it's actually available in earlier versions but much better in MySQL 4). See the MySQL manual for more information. Otherwise, you'll need to parse the search box data to break it up into individual words, then create a query like... WHERE column LIKE '%$var1%' AND column LIKE '%var2%%'... This will be slow, so make sure your database uses indexes. Again, see the MySQL manual for more. Larry

« previous php.general (#165683) next »