Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    405
    Thanks
    17
    Thanked 2 Times in 2 Posts

    fulltext score as percentage

    I'm trying to show the search results scores as percentages, but I'm only getting '0%'

    any thoughts?

    I've got this:
    Code:
    $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>'; }

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,396
    Thanks
    8
    Thanked 1,078 Times in 1,069 Posts
    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']; }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •