vzwhaley Posted April 3, 2006 Share Posted April 3, 2006 How do you format the relevance or score in results from a full text MySQL search? I just can't seem to get the math correct. My results are displaying fine, and I realize that the results are sorted based on the highest relevance or score, but I would like to display the relevance, such as 100%, 99%, etc. and have the number rounded so the viewer can see for themselves how high the ranking is for a certain search. Any suggestions would be much appreciated. Thanks![code][PHP]<? $strTemp = trim($_REQUEST['txtSearch']); mysql_select_db($database); $sql = "SELECT *, MATCH(Name) AGAINST ('$strTemp') AS score FROM ObitData WHERE MATCH(Name) AGAINST('$strTemp') ORDER BY score DESC";while ($Search = mysql_fetch_array($Recordset1)) { $val = round(($Search['score'] / mysql_num_rows($Search)) * 100);echo "Result: " . $val . "% " . $Search['Name'] . "<br>";}?>[/PHP][/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.