使用php和time()仅显示mysql数据库中的某些项
有没有办法在php mysql数组中只显示比某个日期早的项目?我使用此查询方法并按lastpost\u cl排序:使用php和time()仅显示mysql数据库中的某些项,php,mysql,sql,Php,Mysql,Sql,有没有办法在php mysql数组中只显示比某个日期早的项目?我使用此查询方法并按lastpost\u cl排序: $query="SELECT * FROM properties ORDER BY lastpost_cl"; $result=mysql_query($query); $num = mysql_num_rows ($result); mysql_close(); 我在想检查时间的方法是: if (time() <= strtotime($lastpost_cl)) {
$query="SELECT * FROM properties ORDER BY lastpost_cl";
$result=mysql_query($query);
$num = mysql_num_rows ($result);
mysql_close();
我在想检查时间的方法是:
if (time() <= strtotime($lastpost_cl)) {
}
if(time()$query=“SELECT*FROM properties WHERE lastpost_cl
这假设您正在使用mysql日期类型之一存储日期。请参阅手册。mysql可以自行完成此操作。只需将查询更改为:
$query="SELECT * FROM properties WHERE lastpost_cl < NOW() ORDER BY lastpost_cl";
$query=“从属性中选择*,其中lastpost\u cl
但是,您应该在sql查询中这样做,因为sql server和web server上的时间可能不同。像这样的查询会使所有内容都超过一周
SELECT
*
FROM properties
where lastpost_cl < now() - INTERVAL 7 DAY
ORDER BY lastpost_cl
选择
*
从属性
其中lastpost_cl
SELECT
*
FROM properties
where lastpost_cl < now() - INTERVAL 7 DAY
ORDER BY lastpost_cl