我在这里看不到明显的东西,似乎无法让它发挥作用......
if (($_GET['date']=='today'))
{
$today = date('Y-m-d', strtotime('today'));
$query = "SELECT * FROM contacts WHERE (contacttype = 'Buyer' OR "
. "contacttype = 'Seller' OR contacttype = 'Buyer / Seller' OR "
. "contacttype = 'Investor') AND date = '$today' ORDER BY date DESC";
}
谢谢!
答案 0 :(得分:1)
你甚至不需要使用PHP告诉MySQL今天是什么,它已经知道了!
SELECT * FROM contacts WHERE (contacttype = 'Buyer' OR contacttype = 'Seller' OR contacttype = 'Buyer / Seller' OR contacttype = 'Investor') AND date = DATE(NOW()) ORDER BY date DESC
假设WHERE子句中的所有其他条件都正确,
答案 1 :(得分:0)
请尝试以下方法:
where DATE(dt) = DATE(NOW())
答案 2 :(得分:0)
SELECT *
FROM contacts
WHERE (contacttype = 'Buyer'
OR contacttype = 'Seller'
OR contacttype = 'Buyer / Seller'
OR contacttype = 'Investor')
AND DATE = CUR_DATE()
ORDER BY DATE DESC`