...

View Full Version : fulltext score as percentage



turpentyne
11-20-2011, 05:30 PM
I'm trying to show the search results scores as percentages, but I'm only getting '0%'

any thoughts?

I've got this:
$max_score = 0;
if($row['score'] > $max_score){ $max_score = $row['score']; } //because we are ordering by score we can assume on the first run this wil be the max score.

while($row = mysql_fetch_array($data)){
echo '<tr>
<td align="left" valign=top width=85px > <a href="view_plant.php?id=' . $row['plant_name'] . '">View</a></td>

<td align="left" valign=top width=315px>'.@number_format(($row['score']/$max_score)*100,0).'% &nbsp;' . $row['taxonomic_genus'] . '&nbsp;'. $row['scientific_name'] . '&nbsp;' . $row['species_hybrid_marker'] . '&nbsp;<font color=#999999>' . $row['genus_hybrid_marker'] . '&nbsp;' . $row['infraspecific_rank'] . '&nbsp;' . $row['infraspecific_epithet'] . '</font></td><td valign=top>' .$row['common_name_english'] . '</td>

</tr><tr><td colspan=3><img src="http://www.twigzy.com/images/line.gif" width=700 height=1></td></tr>';
}
echo '</table><br><br>'; }

mlseim
11-20-2011, 05:54 PM
Let's look at these lines:

$max_score = 0;
if($row['score'] > $max_score){ $max_score = $row['score']; }

Your $row['score'] must be zero?

test it ...

$max_score = 0;
echo "score: ".$row['score'];
exit;
if($row['score'] > $max_score){ $max_score = $row['score']; }



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum