For a search facility on my website I want to get a bunch of rows where any words match, then I want to go through the record set and assign relevance values according to which/how many fields match search terms.
I've done this but what I want to do now is sort the records according to how many terms match the search term. So it seems best to assign this AFTER the query is recturned, and I'm unsure how to sort this.
The query is like
SELECT fields... FROM tables... INNER JOIN more tables... WHERE field LIKE searchstring OR field2 LIKE searchstring etc...
then, going through the results:
while($row != mysql_fetch_array($newTable)) {if (stripos($searchstring, $subCatName)> -1) $ranking += 60; else if (stripos($altstring, $subCatName) -1) $ranking += 60; if (stripos($searchstring, $catName)> -1) $ranking += 60; else if (stripos($altstring, $catName) -1) $ranking += 60; if (stripos($searchstring, $prodName)> -1) $ranking += 20; else if (stripos($altstring, $prodName) -1) $ranking += 20; if (stripos($searchstring, $desc)> -1) $ranking += 10; else if (stripos($altstring, $desc) -1) $ranking += 10; $row['ranking'] = $ranking;}
but what do I do now?
Many thanks