score on fulltext search converted to percantage
Posted: Fri Oct 08, 2004 3:03 am
hey people,
this is my code snipper for searching. Here i want to show the score by percentaqge but i couldn't find a way to do this? how can I do it? it shows for example 3.43957395759
thanks for your help.
Code: Select all
<?php
public function searchQuery($query) {
$sql = mysql_query("SELECT filename, fileurl, MATCH (keywords) AGAINST ('".addslashes($query)."') AS score FROM mudcrawl WHERE MATCH (keywords, filename, fileurl) AGAINST ('".addslashes($query)."' IN BOOLEAN MODE) ORDER BY score DESC");
if($sql) {
$this->resultcount = mysql_num_rows($sql);
if($this->resultcount > 0) {
echo $this->resultcount." results found:<br>";
while ($row = @mysql_fetch_assoc($sql)) {
echo "<a href="".$row["fileurl"]."">".$row["filename"]."</a> - Score: ".$row["score"]."<br>";
}
}
else {
echo "No results found, click <a href="index.php">here</> to search again.";
}
}
else {
die(mysql_error());
}
}
?>