php数据分页显示,国民老实人九轩博客

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
       
        <?php
       echo "<link href='ys.css' rel='stylesheet'>";
       header("content-type:text/html;charset=utf-8");
       include'conn.php';
       $display=4;
       $result=mysqli_query($conn,"select*from x order by stuid");
       $total= mysqli_num_rows($result);
       $start=(isset($_GET['start']) && ctype_digit($_GET['start']) && $_GET['start']<=$total)?$_GET['start']:0;
       mysqli_data_seek($result,$start);
       echo "<table>";
       echo "<tr><th>学号</th><th>姓名</th><th>性别</th></tr>";
       $count=0;
       while($count++<$display && $arr= mysqli_fetch_assoc($result)){
           echo "<tr><td>{$arr['stuid']}</td><td>{$arr['stuname']}</td><td>{$arr['stusex']}</td></tr>";
       }
       echo "<tr><td colspan=3>";
       if($start>0){
           echo "<a href={$_SERVER['PHP_SELF']}?start=0>|第一页|</a>";
           echo "<a href={$_SERVER['PHP_SELF']}?start=".($start - $display).">|上一页|</a>";
       }
       if($total>($start+$display)){
           echo"<a href={$_SERVER['PHP_SELF']}?start=".($start+$display).">|下一页|</a>";
           $lastpage=($total%$display==0)?($total-$display):($total-$total%$display);
           echo "<a href={$_SERVER['PHP_SELF']}?start=".$lastpage.">|最后一页|</a>";
       }
       if($total>$display){
           $totalpage= ceil($total/$display);
           echo "共有".$totalpage."页";
           $currentpage=ceil($start/$display+1);
           echo"现在是第".$currentpage."页";
       }
       echo"</td></tr>";
       echo"</table>";
        ?>
    </body>
</html>


国民老实人九轩博客qq203239351