Well, the way I'd do it (perhaps not the easiest way mind you) would be to create an array containing "noise" words you want to exclude, ereg out the noise words, and then use the IN() function in your sql statement. For example, assuming that search string is "STRATFORD UPON AVON", the column name is keywords:
<?php
// first we need the create and fill the noise word array (note the
// whitespace so as not to remove char combo's within words)
$noise_words[] = " at ";
$noise_words[] = " of ";
$noise_words[] = " or ";
$noise_words[] = " the ";
$noise_words[] = " and ";
$noise_words[] = " upon ";
// now we to convert the search string to all lowercase and trim any
// whitespace
$searchstring = strtolower(trim($searchstring));
// now loop through the noise words array
while (list(,$var) = each($noise_words)) {
// replace any of the noise words with a null space
$searchstring = eregi_replace($var, " ", $searchstring);
}
// the $searchstring var is now equal to "STRATFORD AVON", time to start
// formating for the IN() function
// the IN() function expects the string to be in a 'word1','word2' format
// first use ereg_replace() to convert the blank spaces between words
// into the single quote, comma, single quote format
$searchstring = eregi_replace(" ", "','", $searchstring);
// now add the start and end single quotes
$searchstring "'" . $searchstring . "'";
// now the string reads "'stratford','avon'", let's create the sql statement
$sql = "SELECT count(keywords) AS score, keywords FROM some_table WHERE keywords IN($searchstring) ORDER BY score DESC";
?>
This statement will select all records which contain the words stratford or avon, ordering the results by the number of words matched. This code doesn't take into account double spaces or any other grammatical mistakes in the search string, but it should give you somewhere to start. Hope this helps!!!
Cheers,
Geoff A. Virgo