我有这段代码
$query = "select * from user";
$result = $mysqli->query($query);
$row = $result->fetch_array(MYSQLI_BOTH);
$IDS=$row['id'];
$num=array($IDS);
arsort($num);
foreach($num as $data){
echo $data;
}
但后来,结果就像8 1 9 6 7 3 4 2 5.如果我这样改变
$num=array(8, 1, 9, 6, 7, 3, 4, 2, 5);
arsort($num);
foreach($num as $data){
echo $data;
}
结果如此9 8 7 6 5 4 3 2 1.结果可以从最大到小排序。如何在阵列上读取$ IDS?
答案 0 :(得分:0)
请使用此行从表中获取数据。无需对数组进行排序。
$query = "select * from user order by id desc";