I have a script that does this:
if ($keyword) {
$k = split(" ", $keyword);
$num_keywords = count($k);
for ($i=0; $i<$num_keywords; $i++) {
if ($i)
$k_string .= "or k.keyword = '".$k[$i]."' ";
else
$k_string .= "k.keyword = '".$k[$i]."' ";
}
$and .= "and ($k_string) ";
}
So, it takes an string of keywords, splits it into an array with "or" inserted. The SQL query it produces then, is as follows:
$sql = "select s.id,
s.headline,
10 * sum(k.weight) / $num_keywords as score
from stories s, keywords k
where s.id = k.story
$and
group by s.id, s.headline
order by score desc, s.id desc";
This is from a very simple CMS I've hacked together using sample code from SAMS; it looks to match items in the 'keyword' table, which shares a 'story id' with the stories table. Each keyword has an associated "score" Not real fancy, but it might be a thought starter...