这个新代码适合我,但不完全,现在的问题是所有用户都有相同的排名,都有1°
<?php
mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die(mysql_error());
mysql_select_db($mysql_db) or die(mysql_error());
$sql = "SELECT ID, Name, username, Wins, Loses, Draws, (Wins + Loses) AS points FROM users WHERE username='$_GET[user]' ORDER BY points DESC";
$result = mysql_query($sql) or die(mysql_error());
if( !$result ){
echo 'SQL Query Failed';
}else{
$rank = 0;
$last_score = false;
$rows = 0;
while( $row = mysql_fetch_array( $result ) ){
$rows++;
if( $last_score!= $row['Wins'] ){
$last_score = $row['Wins'];
$rank = $rows;
}
echo "rank ".$rank." is ".$row['Name']." with point ".$row['Wins']."";
}
}
?>
我需要
Example:
ID username Wins Loses
1 demo 12 12 RANKIG= 1°
2 demo2 1 3 RANKIG= 2°
答案 0 :(得分:0)
尝试将您的查询视为:
<link href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.js"></script>
<div id="ageChart"></div>