|
Posted by Jacob.Lyles@gmail.com on 02/18/06 08:42
See if this helps. Sorry if it doesn't work, I'm new at this.
Near the bottom of the while loop, I set the current value of
$rs[total] to a new variable called $temp_total then I move to the next
record in the record set. If the total of the next record is the same
as the total from the previous record I will not increment $i, so the
rank will be the same. The result is that I display all the records
from the table in descending order and any records that have the same
total will have the same rank. Here it is:
if (!isset($submit)) {
$sql ="select pkey,total from `quiz_percentile` order
by total desc";
$percentile = mysql_query($sql) or die (mysql_error());
$rs = mysql_fetch_array($percentile);
$i=0;
while ($rs) {
if ($rs[total] != $temp_total) {
$i++ ;
}
echo "Your total is ".$rs[total]." your rank is ".$i."
and your pkey is ".$rs[pkey];
$temp_total = $rs[total];
$rs = mysql_fetch_array($percentile);
}
}
Navigation:
[Reply to this message]
|