if(isset($_POST['last']))
{
$s=mysql_query("select * from appointment where `date` >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)");
echo $s;
while($last=mysql_fetch_array($s))
{
echo $last['date'];
echo $last['doctor'];
}
}
如何在点击按钮后从表中获取最近7天的记录,日期的字段名称是"日期"
答案 0 :(得分:1)
您的查询应如下所示------
SELECT * FROM appointment WHERE `date`>= DATEADD(day, -7, GetDate())
答案 1 :(得分:1)
SELECT * FROM `appointment` WHERE `date`>= DATE_SUB(CURDATE(),INTERVAL 7 DAY)
使用上述查询解决方案。
答案 2 :(得分:0)
试试这个好友!
WHERE date <= NOW() AND date >= DATE_SUB(date, INTERVAL 7 DAY)