gpt4 book ai didi

php - 按日期排序(最新)

转载 作者:IT王子 更新时间:2023-10-29 00:31:22 26 4
gpt4 key购买 nike

现在我正在使用下面的查询按每篇文章的 auto_increment id 排序

mysql_query("SELECT * FROM articles ORDER BY id DESC");

我想知道如何按我创建的日期字段进行排序,该字段通过 strtotime() 存储当前日期,它应该查询从最新到最旧的日期。

当前代码

$alist = mysql_query("SELECT * FROM articles ORDER BY id DESC");
$results = mysql_num_rows($alist);

if ($results > 0){
while($info = mysql_fetch_array($alist)) {
// query stuff
echo $info['time'];
}

最佳答案

只需更改 ORDER BY 中的列:

SELECT * FROM articles ORDER BY time DESC

关于php - 按日期排序(最新),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3376458/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com