嗨我想簡單地添加1,2,3,4,5,6,7,8,9,10等級。Mysql添加簡單排名表
我的輸出現在給出如下:
USER ID | SCORE
2 | 10242
13231 | 3427
23732 | 3378
24638 | 2934
23468 | 1898
我儘量做到的是:
RANK | USER ID | SCORE
#1 | 2 | 10242
#2 | 13231 | 3427
#3 | 23732 | 3378
#4 | 24638 | 2934
#5 | 23468 | 1898
這是我的PHP:
<?php $result = mysql_query("SELECT * FROM `users_score` ORDER BY `users_score`.`score` DESC LIMIT 0 , 10") or die(mysql_error());
if(mysql_num_rows($result) > 0): ?>
<table>
<tr>
<th style="text-align:left;">ID</th>
<th style="text-align:left;">SCORE</th>
<tr>
<?php while($row = mysql_fetch_assoc($result)): ?>
<tr>
<td><?php echo $row['user_id']; ?></td>
<td style="font-weight: bold; color: #008AFF;"><?php echo $row['score']; ?></td>
</tr>
<?php endwhile; ?>
</table>
<?php endif; ?>
有一個簡單的像數這個功能?
非常感謝! – swordsecurity 2013-02-12 23:43:17