求php代码分页程序求php代码分页程序求php代码分页程序求php代码分页程序

解决方案 »

  1.   

    我也求个。
    [email protected]谢谢
      

  2.   

    <br>
    <H5 style={font-size:50px;color:red}><div align=center>Test!</div></h5>
    <?
    $time=date("r");echo $time;
    ?>
    <hr style={color:red}>
    <style type=text/css>
    A:link{text-decoration:none; color:#808080};
    A:visited{text-decoration:none;color:orange};
    A:active{text-decoration:none};
    A:hover{text-decoration:underline;color:#000000;background-color:#B6D7FC};
    td{background:white;font-size:20Px;background-color:yellow};
    </style>
    <?
    include("product.php");
    ?>
    <?php
    //获取当前页数
    if(isset($_GET['page'])){
    $page = intval($_GET['page']);
    }
    else{
       $page = 1;
    }// 每页数量
    $PageSize =80;
    $offset=($page-1)*$PageSize;
    //require_once("connToMysql.php");
    $link=mssql_connect("localhost","root","123");mssql_select_db("wangyonghai");
    // 获取总数据量$sql = "select count(*) as amount from shoptest";
    $result = mssql_query($sql);
    while($row = mssql_fetch_array($result)){
    $amount = $row['amount'];
    //echo "first".$amount;
    }
    // 记算总共有多少页
    if($amount){
       if( $amount < $PageSize ){ $page_count = 1; }              
       if( $amount % $PageSize ){                                
           $page_count = intval(($amount/$PageSize) + 1);        
       }
       else
       {
           $page_count =$amount/$PageSize;                   
       }
    }
    else{
    $page_count=0;
       $page_count = 0;
    }
    session_register("page_count");
    ?>
    <?php
    $sql1="select top $PageSize * from shoptest where (seq>".(($page-1)*$PageSize).")";
    $res=mssql_query($sql1);while($ar1=mssql_fetch_array($res)){
    echo "<table width=100% div align=center border=1><tr>";
    echo "<td width=200>";
    echo $ar1['seq'];
    echo "</td>";
    echo "<td width=300>";
    ?>
    <?php
    for($i=0;$i<100;$i++){
    $ptem=$tem1[$i][0];
    if($ptem==$ar1['type']){
    }
    }
    echo $tem2[$i][1]."\n<font color=red>".$ar1['type']."被替换</font>";
    echo "</td>";
    ?>
    <?php
    echo "<td width=150>";
    echo $ar1['num'];
    echo "</td>";
    echo "</tr>";
    echo "</table>";
    }
    ?>
    <br>
    <br>
    <?php
    echo "<hr>";
    if($page==1){
    echo "<a href=t1.php?page=1>第一页</a>\n";
    echo "<a href=t1.php?page=".$page_count.">最后一页</a>\n";
    echo "<a href=t1.php?page=".($page+1).">下一页</a>\n";
    echo "总共有<font color=blue>".$page_count."</font>页";
    }
    else
    {
    echo "<a href=t1.php?page=1>首页</a>\n";
    echo "<a href=t1.php?page=".($page-1).">上一页</a>\n";
    echo "<a href=t1.php?page=".($page+1).">下一页</a>\n";
    echo "<a href=t1.php?page=".$page_count.">最后一页</a>\n";
    echo "总共有<font color=blue>".$page_count."</font>页\n";
    echo "<font color=blue>当前是第</font><font color=red size=6>".$page."</font>页";
    }
    ?>
    <form action="t1.php"  method="get">
    输入要跳到的页面:<input type="text" name="page"><br>
    <input type="submit" value="GO">
    </form><br><br><br><br>
    <?php
    mssql_close($link);
    ?>