Reply to Re: Urgent help for quiz ranking logic

Your name:

Reply:


Posted by cvanschalkwijk on 02/23/06 21:52

If you have the pkey at the start of this, you can just generate rank
and get the total pretty easily on the fly. Of course this require's
MySQL 5 w/ nested query support. This way you aren't messing with your
records and if you insert or update your database it will generate
everyone's rank accurately on the fly when it is requested. Index your
total field and you should be fine even for large databases.

$result = mysql_query("SELECT total, (COUNT( * ) +1) AS rank FROM
quiz_percentile WHERE total > ( SELECT total FROM quiz_percentile WHERE
pkey =$id )")'
while($myrow=mysql_fetch_array($result))
{
$myRank = $myrow["rank"];
$myTotal = $myrow["total"];
}

echo "Your total is $myTotal your rank is $myRank and your pkey is
$id";

- Clay

[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

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