This is for a website search function, I do the following to get several similar results from the mysql database:
$var = "words words words";
$str = explode(' ', $var);
foreach ($str as $i)
{
$match[] = " e LIKE '%$i%' ";//to search each word within searched phrase separately
}
$query = "SELECT * FROM db WHERE a LIKE '%$var%' OR b LIKE '$var%' OR c LIKE '%$var%' OR " . implode(' OR ', $match);
But using this method isn't good since all the data is in no order, I would like to order it by relevance. Please reccommend the simplest methods of doing this. Especially if there's one which doesn't require the redesigning of the whole database, something simple would be good (if a simple method exists)
If the database contained values such as:
"wordy" and "word and word" and "word word word word word"
I would want them in the order of:
"word word word word word" then "word and word" then "wordy"
Hope the above isn't difficult to understand