gpt4 book ai didi

php - 选择今天的日期

转载 作者:行者123 更新时间:2023-11-29 02:24:08 24 4
gpt4 key购买 nike

表:id, confess, user_ip, time, url, loves, hate

时间就像1413040760

$q = mysql_query("SELECT * FROM confessions where time >= unix_timestamp(curdate() + interval 1 day)") or die(mysql_error());

我需要当天最好的忏悔 按爱限制 1 订购。这显示我只有空白,没有结果。

最佳答案

您正在查询从现在起一天之后发生的记录 - 即将来。据推测,你没有任何这样的记录。您可以将 + interval 1 day 更改为 - interval 1 day 以获取在 前 1 天发生的记录。

$q = mysql_query("SELECT * FROM confessions where time >= unix_timestamp(curdate() - interval 1 day)") or die(mysql_error());

编辑:要回答评论中的问题,是的,可以按 loves - hates 排序 - 只需添加一个 order by 子句:

$q = mysql_query("SELECT * " .
"FROM confessions " .
"WHERE time >= unix_timestamp(curdate() - interval 1 day) " .
"ORDER BY (loves - hates) DESC" ) or die(mysql_error());

关于php - 选择今天的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26326062/

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