也就是说你现在的程序给你显示顺序反了??
那把这个
$a="select * from shijian order by date desc limit $offset,$page_size"; //(按时间排序)
改成
$a="select * from shijian order by date limit $offset,$page_size"; //(按时间排序)

解决方案 »

  1.   

    整个代码逻辑很混乱嘛~~~怎么一开始就冒了个$result出来?是什么?
      

  2.   

    to zxyufan(宇凡)
    这是完整的程序:<?
    $link=mysql_pconnect("localhost","root");
    mysql_select_db("mingda",$link);
    $query="select * from shijian";
    $result=mysql_query($query);
    $page_size=3; //(每页显示3个)
    if($page<=0)
    {$page=1;}
    $nums=mysql_num_rows($result);
    $page_count=ceil($nums/$page_size);
    $offset=($page-1)*$page_size;
    $a="select * from shijian order by date limit $offset,$page_size"; //(按时间排序)
    $result=mysql_query($a) or die("浏览失败");
    $prevpage=$page-1;
    $nextpage=$page+1;
    echo "目前留言板上共有".$nums."条留言,本页列出了第".$offset."至".$page_count."条\n"."<br>"; //($page_count这个变量怎么不变呀,老是显示3,怎么才能让它跟着变呀)
    if ($page<=1) 
          echo "第一页"." | ";
    else 
          echo "<a href='$PATH_self?page=1'>第一页</a>"." | ";
    if ($page<2) 
          echo "上一页"." | ";
    else
          echo"<a href='$PATH_self?page=$prevpage'>上一页</a>"." | ";
    if ($page+1>$page_count) 
          echo "下一页"."<br>";
    else
          echo"<a href='$PATH_self?page=$nextpage'>下一页</a>"."\n<br>";
    while ($array=mysql_fetch_array($result))
          {
            echo $array['delid']."\n";
            echo $array['yonghu']."\n";
            echo $array['mima']."\n";
            echo $array['email']."\n";
            echo $array['info']."\n"."<br>";
          }
    ?>可我按你说的试了一下,还是没有改变,其运行结果是:目前留言板上共有8条留言,本页列出了第0至3条 (第一页)目前留言板上共有8条留言,本页列出了第3至3条 (第二页)目前留言板上共有8条留言,本页列出了第6至3条 (第三页,也就是最后一页)
      

  3.   

    来~~我们看看你的$page_count是怎样产生的..首先$nums=mysql_num_rows($result);
    这里的$result是select * from shijian出来的,所以$num是个固定数,跟哪一页没有关系。然后
    $page_size=3; //(每页显示3个) 
    $page_count=ceil($nums/$page_size);$page_size也是固定的数,跟哪一页没关系。那你说$page_count它能不是固定的数?能跟在哪一页有关系吗?
      

  4.   

    我知道$page_count是个固定的变量,但我实在是不知怎么改了,所以发了这个贴子,我是刚学php,还在学习与熟悉之中,望版主告之
      

  5.   

    $a="select * from shijian order by date desc limit $offset,$page_size"; //(按时间排序)
    $result=mysql_query($a) or die("浏览失败");
    后面加:
    $nums=mysql_num_rows($result);
    $page_count=ceil($nums/$page_size);
      

  6.   

    我按你说的又试了一次,可这次的显示结果是:目前留言板上共有3条留言,本页列出了第0至1条 
    第一页 | 上一页 | 下一页
    8 ffff [email protected] 第八个例子 
    7 dsa [email protected] 第七个例子 
    6 00000 [email protected] 第六个例子 出完这页以后,就完了,都不能进入下一页了??????
      

  7.   

    我正在做的论坛,抽几段出来给你,也许有帮助//得到文章总数及以20为一页的总页数
    $query="select count(*) from guestbook";
    $result=mysql_query($query);$arr=mysql_fetch_array($result);
    $num=$arr["count(*)"];
    $num2=intval($num/20);  //显示20篇每页
      for($i=0;$i<=$num2;$i++)
      {
        echo "<td><a href='list.php?from=".($i*20+1);
        echo "'>".($i*20+1)."</a>&nbsp&nbsp</td>";
      }  <!--文章信息列表标题__>
      <tr bgcolor=#ddddaa>
      <td width=10% nowrap ><font style="font-size:14">序号</font></td>
      <td width=45% nowrap ><font style="font-size:14">标题</font></td>
      <td width=20% nowrap ><font style="font-size:14">作者</font></td>
      <td width=25% nowrap ><font style="font-size:14">日期</font></td>
      //检查调用时是否使用参数from,如果没有,则从第一篇开始
      if($from=="")
         $from=1;
      $to=$from+19;
      if($to>$num)
         $to=$num;  //从数据库中取出本页内容
      $query="select id,subject,author,email,date from guestbook
               where id>='$from' and id<='$to' order by date";
      $result=mysql_query($query);
      $num3=mysql_num_rows($result);  //如果没有文章
      if($num3==0)
      {
        echo "<tr><td width=100% nowrap ><font color=#ff0000 style='font-size:14'>";
        echo "<br><br>本页目前没有文章!</font></tr><br><br>";
      }  //列表下方提供同样的连接
      for($i=0;$i<=$num2;$i++)
      {
        echo "<td><a href='list.php?from=".($i*20+1);
        echo "'>".($i*20+1)."</a>&nbsp&nbsp</td>";
      }
      

  8.   

    <?
    //分页控制类
    //宇凡 8月15日
    ?>
    <?
    class PageControl
    {
    var $PageAmount; //总页数
    var $RecordAmount; //总记录数
    var $Page; //当前页码
    var $RecordRow_Per_aPage = 5; //每页显示的记录条数,事先预定,不通过程序更改
    var $NextPage; //下一页的页码
    var $PriorPage; //上一页的页码
    var $StartIndex; //相当于每页显示的起始位置的索引
    var $UsingIndex; //当前使用的数据的索引
    var $arrIDList; //保存ID的数组function PageControl($IDList,$PageNow)
    {
        if (($PageNow == "") || (round($PageNow) <= 0) )
    {
    $PageNow=1;
    }
    $this->arrIDList = $IDList;
        $this->Page = $PageNow;
        $this->RecordAmount = count($IDList);    if ($this->RecordAmount % $this->RecordRow_Per_aPage == 0) {
          $this->PageAmount = $this->RecordAmount / $this->RecordRow_Per_aPage;
        } else {
          $this->PageAmount = ceil($this->RecordAmount / $this->RecordRow_Per_aPage);
        }

    if ($this->Page > $this->PageAmount)
    {
    $this->Page = $this->PageAmount;
    }
        $this->StartIndex = ($this->Page - 1) * $this->RecordRow_Per_aPage;
        $this->UsingIndex = $this->StartIndex - 1;  //这里减一的目的:得到数据的普遍方法是先Next()再Get数据,比如数据集.    if ($this->Page != $this->PageAmount) {
          $this->NextPage = $this->Page + 1;
        } else {
          $this->NextPage = $this->PageAmount;
        }    if ($this->Page != 1) {
          $this->PriorPage = $this->Page - 1;
        } else {
          $this->PriorPage = 1;
        }
    }function next_record()
    {
        $result = false;
        if (($this->UsingIndex != $this->RecordAmount - 1) && ($this->UsingIndex - $this->StartIndex < ($RecordRow_Per_aPage - 1))) {
          $this->UsingIndex += 1;
          $result = true;
        } else {
          $result = false;
        }
        return $result;
    }function get()
    {
        $result = $this->arrIDList[$this->UsingIndex];
        return $result;
    }function show_NowPage()
    {
    echo "<font color=red>".$this->Page."</font>/".$this->PageAmount;
    }function show_FirstLink()
    {
    echo " <a href=".$PHP_SELF."?p=1>最前页</a> ";
    }function show_PriorLink()
    {
    echo " <a href=".$PHP_SELF."?p=".$this->PriorPage.">上一页</a> ";
    }function show_NextLink()
    {
    echo " <a href=".$PHP_SELF."?p=".$this->NextPage.">下一页</a> ";
    }function show_LastLink()
    {
    echo " <a href=".$PHP_SELF."?p=".$this->PageAmount.">最后页</a> ";
    }function show_JumpForm()
    {
    echo "<FORM METHOD=POST ACTION=".$PHP_SELF.">直接到<INPUT TYPE=text NAME=p size=2 class=input>页 <INPUT TYPE=submit value=GOGOGO class=bottem></FORM>";
    }}
    ?>