我正在尝试按升序对分数进行排序。
这是表格:
以下是我使用
的代码$sql = "SELECT * FROM scores";
$myData = mysql_query($sql);
echo "<table class='table table-hover table-bordered table-striped'>
<tr>
<th>Username</th>
<th>Email</th>
<th>Score</th>
</tr>";
while($record = mysql_fetch_array($myData)) {
echo "<tr>";
echo "<td>" . $record['id'] . "</td>";
echo "<td>" . urldecode($record['email']) . "</td>";
echo "<td>" . $record['score'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
<?php
$str="@";
echo htmlentities($str);
?>
答案 0 :(得分:0)
更改SQL
语句以包含ORDER BY
子句
$sql = "SELECT * FROM scores";
应该变成
$sql = "SELECT * FROM scores
ORDER BY score ASC";
分数是您要排序的列,而ASC是数据的顺序