gpt4 book ai didi

php - SQL 查询无法正确构建

转载 作者:行者123 更新时间:2023-11-30 00:12:59 24 4
gpt4 key购买 nike

我做了一个查询,显示了指定月份内观看次数最高的 5 个结果;带有静态日期的查询本身工作正常,但是当我尝试使用 date() 函数获取当前年份和月份时,它不起作用:

$currentmonth = date("m");
$nextmonth = $currentmonth++;
$gethotbookq = mysqli_query($con,"SELECT BookID, COUNT(*) AS `num` FROM `BOOKS_views` WHERE `TIME` >= '2014- $currentmonth-01 00:00:00' and `TIME` < '2014-$nextmonth-01 00:00:00' GROUP BY `BookID` LIMIT 5") or die();

最佳答案

 $currentmonth = date("m");
$nextmonth = date("m", strtotime(" +1 month"));
$gethotbookq = mysqli_query($con,"SELECT BookID, COUNT(*) AS `num` FROM `BOOKS_views` WHERE `TIME` >= '2014-$currentmonth-01 00:00:00' and `TIME` < '2014-$nextmonth-01 00:00:00' GROUP BY `BookID` LIMIT 5") or die();

关于php - SQL 查询无法正确构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23895860/

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