RE: [PHP-DB] Help with search engine and splitting values needed :-( From: Beau Lebens (B.Lebens <email protected>)
Date: 10/14/01

you would need to do something like

$search_this = "SELECT * FROM table WHERE";
$words = split(" ", $search_terms);
foreach($words as $word) {
        $search_this .= " field LIKE '%$word%' OR";
}
$search_this = substr($search_this, 0, strlen($search_this)-3);

of course i didn't test any of that at all, but something like that should
help you out hopefully :)

// -----Original Message-----
// From: Chris Payne [mailto:chris <email protected>]
// Sent: Monday, 15 October 2001 10:01 AM
// To: php-db <email protected>
// Subject: [PHP-DB] Help with search engine and splitting values needed
// :-(
//
//
// Hi there everyone,
//
// I currently have a partially written search engine for a
// client and it works fine using the WHERE / LIKE settings
// (I'm using MySQL with the latest PHP for Windows to
// program). My question is this:
//
// Currently if you enter a single word it searches fine - if
// you enter afr it will bring all entries for africa or
// anything similar to afr which is what I need. However, how
// do I make it so that if they enter several words on the line
// that it searches for each word? I know it's probably
// straight forward to most people, but i'm stumped.
//
// I guess it needs to split the string from the form and then
// run the LIKE command on each string, but I don't know how to
// split the string and then get the DB to read each one?
//
// Any help would be sincerely appreciated - in newbie form
// though please :-)
//
// Thank you.
//
// Chris Payne
// chris <email protected>
// http://www.planetoxygene.com
//

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>