This is more of a php question. explode $string on " " (space) which will give you an array. Loop through the array first with $sql.="WHERE whatevercolumn LIKE '%$val%'" then for every other entry change WHERE to AND.
Serge. ----- Original Message ----- From: "Paul Maine" <[EMAIL PROTECTED]> To: "MySQL MySQL" <[EMAIL PROTECTED]> Sent: Saturday, July 27, 2002 10:32 PM Subject: PHP/MySQL Search Engine Query Question > I am currently working on a website that is implemented using PHP and MySQL. > > The site currently has a simple search engine that allows a shopper to type > in a search string that is stored in $search. For example, if a shopper > types in 1972 Ford Mustang > $string ="1972 Ford Mustang" > > Using the following SQL statement: > SELECT * FROM whatevertable WHERE whatevercolumn LIKE '%$search% > > Records are returned that have this exact string and in this exact order > (I'm aware a wild card character is included on the front and back of the > string). > > My desire is to be able to logically AND each token of the search together > independent or the order of the tokens. > I want to return all records that have Mustang AND 1972 AND Ford. > > Since a shopper inputs the search string in advance I don't know how many > tokens will be used. > > I would appreciate any suggestions. > > Regards, > Paul > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php