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>";
 
}

Recommended Answers

All 4 Replies

Do you mean double as in it echos 1.15 or it displays 0.575 twice?

it 0.575 twice

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>";

ooo...
thank you.
yes, dat fixed my problem..
:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.