我想按降序排列數據,但輸出的數據不正確。我希望數據以降序排列,但我得到了不正確的輸出php
<?php
$selxx = "select * from a_points where type='class' GROUP BY en_no DESC";
$exxx = $con->query($selxx);
$ai = 0;
while($fetp = $exxx->fetch_object())
{
if($ai <= 4)
{
$ai++;
}
else
{
break;
}
$points = 0;
$temp = $fetp->en_no;
$selt = "select * from a_points where en_no='$temp'";
$ext = $con->query($selt);
while($fett = $ext->fetch_object())
{
$points = $points + $fett->points;
}
?>
<tr>
<td><?php echo $ai; ?></td>
<td><?php echo $fetp->en_no; ?></td>
<td><?php echo $fetp->st_name; ?></td>
<td><?php echo $points; ?></td>
</tr>
<?php } ?>
結果:
我想什麼:
1 150570116027卡蘭97
2 160573116003拉維70
3 15097116013 Krish 40
4 150570116002依禪20
'$ selxx =「select * from a_points where type ='class'ORDER BY en_no DESC」; $ exxx = $ con> query($ selxx);'orderby not groupby – Hemakumar
格式化的代碼塊。固定圖像鏈接。簡化的語言。 – Merec