PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?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());
}
}
?>
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.
well i think i've done it, but some enhancements would be great. In my sql above how can I select only the results which has a relevance greater than zero?