我尝试只显示在最后一天提交的文章,限制为5,但我有一个问题,如果在一个类别中存在少于5篇文章,我不想显示重复,只显示1,2,3,4篇文章,怎么办?谢谢!
$Time=time();
$LimitDay=$Time - 86400;
$SelectArticle=mysqli_query($ConnecDB, "SELECT * FROM mk_sn_article WHERE art_category='$Display[CategorieMail]' AND art_data BETWEEN '$LimitDay' AND '$Time' ORDER BY art_id DESC LIMIT 5");
答案 0 :(得分:0)
SELECT * FROM mk_sn_article WHERE art_category='$Display[CategorieMail]' AND art_data > DATE_SUB(NOW(), INTERVAL 1 DAY) ORDER BY art_id DESC LIMIT 5
只需使用DATE_SUB
进行比较 - 它将拉出所有-24h文章