如何产生排名

时间:2018-09-01 13:08:04

标签: php

我尝试从数据库生成排名,但0(零)值始终显示Rank-1。

我的代码

<?php $ra ="
 SELECT SUM(TermOneWritten),  FIND_IN_SET( TermOneWritten, (    
 SELECT GROUP_CONCAT(DISTINCT TermOneWritten
 ORDER BY TermOneWritten DESC) 
 FROM std_result WHERE StudentID =  '".$studentID."' GROUP BY StudentID)
 ) AS rank
 FROM std_result
 WHERE StudentID =  '".$studentID."' GROUP BY StudentID";
 $res = mysqli_query($mysqli, $ra);
 while($r=mysqli_fetch_array($res)){
   echo "RANK -  " . $r["rank"]. "";
 }
 ?>

0 个答案:

没有答案