【问题标题】:Forums Table Ranking Help (PHP / HTML)论坛表格排名帮助 (PHP / HTML)
【发布时间】:2016-07-30 20:41:04
【问题描述】:

我最近创建了一个论坛,其中包含一个显示数据的表格。

<div class="invis">
<div class="topic-top">
<table width="100%"><tr>
<td width="54%" style="color:white;">Topic</td>
</table>
</div>
<div class="topic-test">
<?php
while($thread=mysql_fetch_assoc($forum)){
echo "<tr>";
echo "<td><a href='threads?id=".$thread['id']."'
     class='btn'>".$thread['title']."</a></td><hr>";
echo "</tr>";
}
?>
</tr>
</table>
</div>

当它显示数据时,它会先显示最旧的数据(按 id)。如何让它首先显示最新?

【问题讨论】:

  • 如果以下答案之一回答了您的问题,本网站的工作方式,您将“接受”答案,更多信息请点击此处:What should I do when someone answers my question?。但前提是你的问题真的得到了回答。如果没有,请考虑在问题中添加更多详细信息。

标签: php html mysql html-table


【解决方案1】:

使用 MySQL 在查询中按 ID 排序。您可以阅读有关 order by 子句here 的更多信息。

ORDER BY id DESC

使用ORDER BY id ASC进行相反的排序。

【讨论】:

  • 谢谢!像魅力一样工作!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-09
  • 1970-01-01
  • 2017-09-21
  • 1970-01-01
  • 2015-10-01
  • 2021-07-07
相关资源
最近更新 更多