这是一段论坛回帖列表代码
显示出来大概是这样的
2楼 xxxx
3楼 XXX
4楼 Xxxxxx
1 2 3 4 下页我现在想把他们倒过来变成4楼 xxxx
3楼 XXX
2楼 Xxxxxx
1 2 3 4 下页怎么办呢??elseif($do == 'replylist') { echo "<br />$lang[thread_replylist]<br /><a href=\"index.php?action=thread&amp;tid=$thread[tid]\">$thread[subject]</a>($thread[replies])<br />--------------";
$wapppp = 10;
$page = max(1, intval($page));
$start_limit = $number = ($page - 1) * $wapppp;
if($page < 2) {
$end_limit = $wapppp + 1;
} else {
$start_limit = $start_limit + 1;
$end_limit = $wapppp;
}
$query = $db->query("SELECT * FROM {$tablepre}posts
WHERE tid='$tid' AND invisible='0'
ORDER BY dateline LIMIT $start_limit, $end_limit");
while($post = $db->fetch_array($query)) {
if(!$post['first']) {
$postlist[] = $post;
}
}
if(!empty($postlist)) {
$number = ($page - 1) * $wapppp + 1;
foreach($postlist as $post) {
$waptlength = 50; echo "<br /><a href=\"index.php?action=thread&amp;do=reply&amp;tid=$post[tid]&amp;pid=$post[pid]\">".++$numbe+10*$page.$lang['floor']."</a>|".($post['authorid'] ? "<a href=\"index.php?action=my&amp;uid=$post[authorid]\">".$post['author']."</a> " : $lang['anonymous'].' ').gmdate("m-d H:i", $post['dateline'] + $timeoffset * 3600);
$needhiddenreply = ($hiddenreplies && $discuz_uid != $post['authorid'] && $discuz_uid != $thread['authorid'] && !$post['first'] && !$forum['ismoderator']);
if($needhiddenreply) {
echo "<br />".$lang['message_ishidden_hiddenreplies'];
} else {
echo "<br />".wapcutstr(trim($post['message']), $waptlength);
} }
echo "<br />".wapmulti($thread['replies'], $wapppp, $page, "index.php?action=thread&amp;do=replylist&amp;tid=$thread[tid]")."<br />";
}

解决方案 »

  1.   

    ... ORDER BY dateline desc ...
      

  2.   

    按楼号id降序排列显示就OK了啊...
      

  3.   

    $query = $db->query("SELECT * FROM {$tablepre}posts
    WHERE tid='$tid' AND invisible='0'
    ORDER BY dateline DESC LIMIT $start_limit, $end_limit");
      

  4.   

    order by id desc.....就是查询的时候,最新的在前面
      

  5.   

    从数据库中获取总的行数,select count(*)from ...或者mysql_affected_rows(),逐渐减小n--,不就行了
      

  6.   

    倒序:
    floor = 总记录数 - (当前页码 - 1) * 每页显示的记录数;//第几楼for($i = 0; ....){
    ......
    currentfloor = floor --;
    ......
    }
    顺序:
    floor = (当前页码 - 1) * 每页显示的记录数;
    for($i = 0; ....){
    ......
    currentfloor = floor ++;
    ......
    }
      

  7.   

    elseif($do == 'replylist') {echo "<br />$lang[thread_replylist]<br /><a href=\"index.php?action=thread&amp;tid=$thread[tid]\">$thread[subject]</a>($thread[replies])<br />--------------";
    $wapppp = 10;
    $page = max(1, intval($page));
    $start_limit = $number = ($page - 1) * $wapppp;
    if($page < 2) {
    $end_limit = $wapppp + 1;
    } else {
    $start_limit = $start_limit + 1;
    $end_limit = $wapppp;
    }
    $query = $db->query("SELECT * FROM {$tablepre}posts
    WHERE tid='$tid' AND invisible='0'
    ORDER BY dateline LIMIT $start_limit, $end_limit");
    while($post = $db->fetch_array($query)) {
    if(!$post['first']) {
    $postlist[] = $post;
    }
    }
    if(!empty($postlist)) {
    //$number = ($page - 1) * $wapppp + 1;
    $number = count($postlist[]) - ($page - 1) * $wapppp;
    foreach($postlist as $post) {
    $waptlength = 50;echo "<br /><a href=\"index.php?action=thread&amp;do=reply&amp;tid=$post[tid]&amp;pid=$post[pid]\">".$number--.$lang['floor']."</a>|".($post['authorid'] ? "<a href=\"index.php?action=my&amp;uid=$post[authorid]\">".$post['author']."</a> " : $lang['anonymous'].' ').gmdate("m-d H:i", $post['dateline'] + $timeoffset * 3600);
    $needhiddenreply = ($hiddenreplies && $discuz_uid != $post['authorid'] && $discuz_uid != $thread['authorid'] && !$post['first'] && !$forum['ismoderator']);
    if($needhiddenreply) {
    echo "<br />".$lang['message_ishidden_hiddenreplies'];
    } else {
    echo "<br />".wapcutstr(trim($post['message']), $waptlength);
    }}
    echo "<br />".wapmulti($thread['replies'], $wapppp, $page, "index.php?action=thread&amp;do=replylist&amp;tid=$thread[tid]")."<br />";
    }
      

  8.   

    18楼gg。。不行啊。。这样的话只是序号倒了。。内容没有倒。。我加了个desc之后。。第一页就多出一贴来也就是11个回帖。不知道怎么回事。。
      

  9.   

    估计是因为$start_limit, $end_limit也是受number控制的、、、、所以我觉得改起来好难。。