There are really two issues here. Querying matches from the database is one. The other is
ranking the responses by (let's call it) keyword density.
The first is easy--just split your query terms on spaces and do an OR query for each of them.
Then run a post-query ranking process where you test each record returned from your query for the presence of each of your search terms, and scores them. Then sort your responses by score, and bob's yer uncle.
Like this:
Code:
//Let's say that array $responses has strings of response values.
foreach ($responses as $record) {
$result[$i++][record] = $record;
foreach ($keyword as $word) {
if (ereg($word, $record)) {
++$result[$i][score];
}
}
}
function user_sort ($a, $b) {
if ($a[score] > $b[score]) {
return 1;
} elseif ($b[score] > $a[score]) {
return -1;
} else { return 0; }
}
sort($result, 'user_sort');
Note that I didn't actually
run this code--this is strictly off-the-top-of-my-head. YMMV greatly.