Posted by Jasen Betts on 02/19/06 03:08
On 2006-02-18, Kapil Jain <kapiljainindore@gmail.com> wrote:
> Dear All,
> Please help me urgently....
>
> below is the test code
try this...
I also modified the SQL to do fewer uodates... if all who score '10' get rank
1 then all uppdates can be done in one query.
><?
> if (!isset($submit))
> {
> $sql ="select pkey,total from `quiz_percentile` order by total desc";
>
> percentile = mysql_query($sql) or die (mysql_error());
> $i=0;
$rank='-1' ; $score=-1;
while ($rs = mysql_fetch_array($percentile))
{
//echo $rs["total"]."This is total"."<br>";
$i++;
if($score != $rs['total'])
{
$rank=$i;
$score=$rs['total'];
$sql_insert = "update quiz_percentile set rank='$rank' "
."where total='$score' ;" ;
$arr = mysql_query($sql_insert) or
die(disp_message(mysql_error(),"javascript:history.back()"));
}
}
> ?>
></body>
></html>
>
--
Bye.
Jasen
[Back to original message]
|