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] Link to comment https://forums.phpfreaks.com/topic/6487-percent-formatting-problem/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.