所以我想在数据库中从最高到最低排序值。 它现在唯一能做的就是随机加扰所有结果,这意味着它只会在中间放置100以下,在顶部放置1。
<?php
$con=mysqli_connect("localhost","username","password","table");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM playerdata ORDER BY Gold");
while($row = mysqli_fetch_array($result)) {
echo $row['Username'];
echo " " . $row['Gold'];
$row['Unique_ID'];
echo "<br>";
}
mysqli_close($con);
?>
答案 0 :(得分:1)
SELECT * FROM playerdata ORDER BY Gold DESC
答案 1 :(得分:1)
Mysql不按值排序,但 Mysql根据类型按值排序。
如果我们举个例子:您的表格TABLE1
包含两列C1
和C2
,C1
为INT
且C2
为{ {1}}我们有一套:
VARCHAR
所以
C1 C2
1 1
2 2
10 10
显示
SELECT * from TABLE1 ORDER BY C1 DESC
但
C1 C2
10 10
2 2
1 1
将显示
SELECT * from TABLE1 ORDER BY C2 DESC
因此请注意您的架构和数据。