<?php $pdo = new PDO('mysql:host=127.0.0.1;dbname=lianxi','root','root'); $page=isset($_GET['page'])?$_GET['page']:1; $sql2="select * from one"; $count=count($pdo->query($sql2)->fetchAll(PDO::FETCH_ASSOC)); $lenth=3; $zys=ceil($count/$lenth); $pyl=($page-1)*$lenth; $pdo->exec('set names utf8'); $up=$page<=1?1:$page-1; $next=$page+1>=$zys?$zys:$page+1; $sql="select * from one limit $pyl,$lenth"; $arr=$pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC); ?> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <form action="9.222.php" method="post"> <input type="text"name="name"/> <input type="submit"value="查询"/> <table border="1"> <tr> <td>编号</td> <td>名字</td> <td>密码</td> <td>时间</td> <td>状态值</td> </tr> <?php foreach ($arr as $key => $val ){ ?> <tr> <td><?php echo $val['id']?></td> <td><?php echo $val['name']?></td> <td><?php echo $val['pwd']?></td> <td><?php echo $val['time']?></td> <td><?php echo $val['sta']?></td> </tr> <?php }?> </table> <a href="9.22.php?page=1">首页</a> <a href="9.22.php?page=<?php echo $up ?>">上一页</a> <a href="9.22.php?page=<?php echo $next?>">下一页</a> <a href="9.22.php?page=<?php echo $zys?>">尾页</a> </form> </body> </html>