Reply to Re: Urgent help for quiz ranking logic

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация