如果我这样做:
ALTER TABLE `equipos11a12` ORDER BY `ID`
只发生过一次。如果我更改了ID,它就不会按升序改变。
我必须每次都运行alter table,以便id命令。
这是我的php代码:
$query = "SELECT * FROM equipos11a12";
$result = mysql_query($query); ?>
while($person = mysql_fetch_array($result)) {
echo " " . $person ["name"] . " ";
答案 0 :(得分:5)
您必须将order by子句添加到您的选择查询中:
$query = "SELECT * FROM equipos11a12 ORDER BY `ID` ASC"; // ascending order
$query = "SELECT * FROM equipos11a12 ORDER BY `ID` DESC"; // descending order