MySQL使用限制,不考虑记录';id';s

MySQL使用限制,不考虑记录';id';s,mysql,limit,Mysql,Limit,我正在写一个类似博客的活动日历,它显示即将到来的活动。过去的事情不再出现了。一切正常,但是我想限制记录的数量,比如说每页10条,然后点击进入下一组 现在我有这个: <?php $past = strtotime('now'); $result = mysql_query("SELECT * FROM data ORDER BY '$thedate' ASC LIMIT 0,10"); while($row = mysql_fetch_object($result)) { $end

我正在写一个类似博客的活动日历,它显示即将到来的活动。过去的事情不再出现了。一切正常,但是我想限制记录的数量,比如说每页10条,然后点击进入下一组

现在我有这个:

<?php
$past = strtotime('now');

$result = mysql_query("SELECT * FROM data ORDER BY '$thedate' ASC LIMIT 0,10");
while($row = mysql_fetch_object($result))
{
    $end_event_date = $row->end_strtotime;
    if($end_event_date > $past) { 
        //display data

只需过滤查询中过去发生的事件。这使您的代码更容易,并解决了您的问题。试试这个:

<?php
$past = strtotime('now');

$result = mysql_query("SELECT * FROM data WHERE end_event_date > NOW() ORDER BY '$thedate' ASC LIMIT 0,10");
while($row = mysql_fetch_object($result))
{
    //display data

谢谢你的快速回答。仍然在挣扎,因为现在事情的表现有所不同,但仍然不是他们应该做的。帖子的数量现在是正确的,但是日期完全乱了。。。我可能忽略了一些简单的东西,现在可以用了。谢谢你的帮助!