如何强制php只显示最后的回复


How can I force php to show ONLY the last replies?

我试图强制php只显示最后一个回复,但它只显示第一个回复。这是我的代码:

if($resp = $replies->selectWhereAt('post_id', $entry['id']))
        {
            if(count($resp)>REPLIES_SHOWN)
                echo '<i>Omitted '.(count($resp)-REPLIES_SHOWN).'  reply's, press [Reply] to show 'em all.</i><br /><br />';
            for($i != 0; $i < REPLIES_SHOWN;  $i++)
                if(!empty($resp[$i]['id'])) // If there is replies...
                {
                    $ip = isAdmin() ? $resp[$i]['ip'] : '';
                    $thumb = empty($resp[$i]['thumb']) ? '<br /><br />' : '<br /> Файл: <a target="_blank" href="'.$resp[$i]['image'].'">'.substr($resp[$i]['image'], strlen(IMAGES_FOLDER)+1).'</a> - ('.round(filesize($resp[$i]['image'])/1024).'kb - '.$w.'x'.$h.') <br /> <a href="'.$resp[$i]['image'].'"><img border="0" src="'.$resp[$i]['thumb'].'" align="left" style="margin:5px" alt="" width="'.TH_W.'" height="'.TH_H.'" /></a>';
                    echo '<div class="box"><a name="'.$resp[$i]['id'].'"></a><span class="subject">'.$resp[$i]['subject'].'</span> <span class="name"> '.tripcode($resp[$i]['name']).'</span> No. <a class="idLink" href="?reply='.$entry['id'].'">'.$resp[$i]['id'].'</a> [<a href="?delete='.$resp[$i]['id'].'&amp;w=r">Delete</a>] [<a href="?report&amp;post='.$entry['id'].'&amp;reply='.$resp[$i]['id'].'">Report</a>] '.$ip.$thumb.hacode($resp[$i]['comment']).'</div><br /><br />';
                }
        }
        echo '<hr /><br />';
    }

p.S.

$replies = new phlat('replies', array('post_id', 'time', 'name', 'email', 'subject', 'comment', 'thumb', 'image', 'pass', 'ip')

我在用Phlat-https://code.google.com/p/phlat

我想通过阅读您的代码,REPLIES_SHOWN是表示您想要显示的回复数量的常量。只是将您的循环介绍更改为:

 for($i = count($resp) - REPLIES_SHOWN - 1; $i < count($resp); $i++)

应该这样做。

我不确定我的答案,因为我会看到函数selectWhereAt('post_id',$entry['id']),这个函数可能会为特定的帖子选择回复,但不会返回数组>1。请参阅变量$resp的var_dump()以了解。。。。