0

hi everyone
I need help regarding my php code.
I used array to insert data in the database.
I want the value will be in ranking system such as:

1 0.575
2 0.456
3 0.327

the thing is the value whic is in the database such as 0.575 will be double when display. how to fix this problem. I got stuck for several days.

here I put my code to rank and display the value:-

$q= "select * from supplier_report order by report_value desc";
$result=mysql_query($q);
$rank = 0;
$points = 0;
$rankIncrement = 1;
while ($user=mysql_fetch_array($result))
{
    if ($user['report_value'] == $points)
    {
        $rankIncrement++;
    }
    else
    {
        $rank += $rankIncrement;
        $rankIncrement = 1;
    }

    echo "$rank";
	echo "<br>{$user['report_value']}</br>";
 
}
3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by just_me
0

Might be wrong but here's a suggestion:

$q= "select * from supplier_report order by report_value desc";
$result=mysql_query($q);
$rank = 0;
$points = 0;
$rankIncrement = 1;
$user=mysql_fetch_array($result);
    if ($user['report_value'] == $points)
    {
        $rankIncrement++;
    }
    else
    {
        $rank += $rankIncrement;
        $rankIncrement = 1;
    }

    echo "$rank";
	echo "<br>{$user['report_value']}</br>";
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.