我只想显示折扣当前的书籍。Dealstart 和 Dealend 代表窗口。但我搞砸了。
$sqlCommand = "SELECT id,bookcover FROM booklist WHERE category1='$bookid' OR category2='$bookid' OR category3='$bookid' AND dealstart >= CURDATE() AND dealend is >= CURDATE()";
您的 SQL 语句中似乎存在语法错误,请删除“is”:
lCommand = "SELECT id,bookcover FROM booklist WHERE category1='$bookid' OR category2='$bookid' OR category3='$bookid' AND dealstart >= CURDATE() AND dealend >= CURDATE()";
如果查询仍然不起作用,请回显“lCommand”并查看它产生了什么,然后尝试针对您的数据库运行该查询。
像这样?
$sqlCommand = "SELECT
id,
bookcover
FROM
booklist
WHERE
category1='$bookid' OR
category2='$bookid' OR
category3='$bookid' AND
dealstart >= CURDATE() AND
dealend >= CURDATE()
ORDER BY
dealend DESC";