用php显示用户的等级

时间:2014-01-19 13:09:53

标签: php mysql

我试图显示用户的排名,这是我当前的代码。

问题是它一直显示等级“2”。

我哪里出错?

   <?
     if(! defined('BASEPATH') ){ exit('Unable to view file.'); }
    $sql = $db->Query("SELECT uid, SUM(`total_clicks`) AS `clicks` FROM `user_clicks` GROUP BY uid ORDER BY `clicks` DESC");
    $user = $db->QueryFetchArray("SELECT uid, SUM(`total_clicks`) AS `clicks`, @rank := @rank + 1 as ranking
    FROM `user_clicks`, (select @rank := 0) r
    GROUP BY uid 
    ORDER BY `clicks` DESC");

    ?>

    RANK # <?=$user['ranking']?>

0 个答案:

没有答案