RE: [PHP] Searching
| From: | Boget, Chris | Date: | Mon, 17 Jul 2000 18:35:37 +0000 |
| Subject: | RE: [PHP] Searching | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-6951@lists.php.net to get a copy of this message | ||
> *sniffle*... i suspected as much, but i was hoping there
> might be a simpler solution involving predefined functions
> or something....
None that I know of, unfortunately.
> oh well, I guess i'll stop whining and try to write that code
> now.
Depending on how complex you want the search routine, it
could be as simple as this:
$searchPhrase = "this that theother";
$searchWords = explode( " ", $searchPhrase );
$query = "SELECT * FROM myTABLE where "
for( $i = 0; ( $i < count( $searchWords ) - 1 ); $i++ ) {
$query .= "search_field LIKE \"%$searchWords[$i]%\" AND ";
}
$query .= "search_field LIKE \"%$searchWords[$i]%\"
ORDER BY record_num";
or what have you...
Chris