我很困惑。
当我发送ORDER BY paramater
desc的查询时,它应该加载并按照该参数的最大数量将行顺序呈现给较低的参数。
这是我正在运行的代码:
<?php
$p = 1;
$loadusers = mysqli_query($con, "SELECT * FROM `users` ORDER BY `gpower` DESC");
$z = 0;
while ($me = mysqli_fetch_array($loadusers)) {
$z++;
if (($z % 20) == 0) {
$p += 1;
}
if ($me['id'] == $userinfo['id']) {
break;
}
}
if (isset($_GET['sp'])) {
$p = intval($_GET['sp']);
}
$sl = (($p * 20) - 20);
$el = $p * 20;
$loadrank = mysqli_query($con, "SELECT * FROM `users` ORDER BY `gpower` DESC LIMIT $sl,$el");
if (mysqli_num_rows($loadrank) < 1) {
$p = 1;
$sl = (($p * 20) - 20);
$el = $p * 20;
$loadrank = mysqli_query($con, "SELECT * FROM `users` ORDER BY `gpower` DESC LIMIT $sl,$el");
}
$i = $sl;
while ($rs = mysqli_fetch_array($loadrank)) {
$i++;
?>
<tr <?php echo ($rs['id'] == $userinfo['id']) ? "style='background: #7d2222';" : ""?>>
<td><?php echo $i; ?></td>
<td><?php echo secure($rs['name']); ?></td>
<td><?php echo secure($rs['troops']); ?></td>
<td><?php echo clanName($con, $rs['name']); ?></td>
<td><?php echo $rs['gpower']; ?></td>
</tr>
<?php
}
?>
任何想法为什么会发生这些人?
答案 0 :(得分:0)
您获得降低的ALPHA订单
将gpower转换为int(在SQL Server中)
...Order by cast(gpower as int) Desc
答案 1 :(得分:0)
好的,问题是我使用了二进制类型gpower
cloumn。
我已将它改为浮动而且有效。
当您使用&#34; ORDER BY paramater
DESC&#34;它仅在参数为数字类型时才有效。