是给mssql的记录分页还是其它的页面显示分页呀

解决方案 »

  1.   

    搜一下呗:
    <?php $qh=mysql_query("SELECT COUNT(*) AS rcnt FROM TABLE WHERE YOUR_CONDITION_HERE ORDER BY WHATEVER"); $data=mysql_fetch_array($qh); $nr=$data["rcnt"]; //判断偏移量参数是否传递给了脚本,如果没有就使用默认值0 if (empty($offset)) { $offset=0; } //查询结果(这里是每页20条,但你自己完全可以改变它) $result=mysql_query("SELECT id,name,phone FROM TABLE WHERE YOUR_CONDITION_HERE ORDER BY WHATEVER LIMIT $offset, 20"); //显示返回的20条记录 while ($data=mysql_fetch_array($result)) { //换成你用于显示返回记录的代码 } //下一步,要写出到其它页面的链接 if(!$offset) //如果偏移量是0,不显示前一页的链接 { $preoffset=$offset-20; print "<a href=\"$PHP_SELF?offset=$preoffset\">前一页</a>&nbsp;\n"; } //计算总共需要的页数 $pages=ceil($nr/20); //$pages变量现在包含所需的页数 for ($i=1; $i <= $pages; $i++) { $newoffset=20*$i; print "<a href=\"$PHP_SELF?offset=$newoffset\">$i</a>&nbsp;\n"; } //检查是否是最后一页 if ($pages!=0 && ($newoffset/20)!=$pages) { print "<a href="$PHP_SELF?offset=$newoffset">下一页</a>&nbsp;\n"; } ?> 
      

  2.   

    select top 100 * from table where id not in(select top $page*$per_record_page id from table order by id) order by id
      

  3.   

    <?
    function getcolor() 

    static $colorvalue;//定义一个静态变量 
    if($colorvalue==cyan) 
    $colorvalue="#ffffff"; 
    else $colorvalue=cyan; 
    return($colorvalue); 
    } function ShowOnePage( $atm, $rows,$No,$table_name ) {
      $atm->seek( $No );
    $atm_field =new DB_atm;
      echo "<TABLE Border=1 Align=Center>";
      echo "<TR BgColor=Cyan><TD>No.</TD>";
      $full=true;
      $field=$atm_field->metadata($table_name,$full);
     // echo "num_fields".$field["num_fields"];
     for( $i=0;$i<$field["num_fields"];$i++ ) {
         echo "<TD>" .$field[$i]["name"] . "</TD>";
      }
      echo "</TR>";  for ( $I=1; $I <= 10; $I++ ) {
    $bcolor=getcolor();//换背景颜色 
        if ($atm->next_record() ) { 
       //echo "aaaaa".$atm->Record["flag"];
           
            echo "<TR bgcolor=$bcolor><TD Align=Right>" . ($No + $I) . "</TD>";
            for ( $K=0 ; $K < $field["num_fields"]; $K++ ) {
               echo "<TD Align=Right>" . $atm->f($field[$K]["name"]). "</TD>";
      // echo "<TD Align=Right>$K" . $atm->f("time"). "</TD>";

            }
            echo "</TR>";
         }
      }
      echo "</TABLE>";
    }
    ?><HTML>
    <BODY bgcolor="#FFFFFF">
    <H2 ALIGN=CENTER>show_atmls.php, 分页浏览(完成版)<HR></H2>
    <?
    $atm = new DB_atm;
    $userid=$_SESSION['userid'];
    $atmno=$_POST['atmno'];
    $atmno='3761';
    $table_name='atmls'.$atmno;
    $atm->connect();
    $sql="select * from $table_name where stcd!='9'";
    $rows=$atm->query($sql);
     
      $num = $atm->num_rows($rows);
      $Pages = intval(($num - 1) / 10) + 1;
      $Page=$_GET['Page'];
      if ( $Page < 1 ) $Page = 1;
      if ( $Page > $Pages ) $Page = $Pages;  ShowOnePage( $atm,$rows, ($Page-1)*10 ,$table_name);
    ?>
    <HR>
    <FORM Action=<?echo $PHP_SELF;?> Method=GET>
    <DIV Align=right>
    <?
    if ( $Page <> 1 ) {  
       echo "<A HREF=$PHP_SELF?Page=1>第一页</A>";
       echo "<A HREF=$PHP_SELF?Page=".($Page-1).">上一页</A>";
    }if ( $Page <> $Pages ){
       echo "<A HREF=$PHP_SELF?Page=".($Page+1).">下一页</A>";
      echo "<A HREF=$PHP_SELF?Page=$Pages>最后一页</A>";
    }?>
    请输入页码:<INPUT TYPE=TEXT Name=Page SIZE=3>
    当前页数:<Font color=Red><?echo $Page;?>/<?echo $Pages;?>
    </DIV>
    </FORM>
    </BODY></HTML>