<?php //引入model类 include './Model.php'; //实例化对象 $mod = new Model('user'); //获取总数据 $count = $mod->count(); //引入page类 include './Page.php'; $page = new Page($count,5); $limit = $page->getLimit(); $show = $page->show(); $res = $mod->limit($limit)->select(); //echo '<pre>'; ///var_dump($res); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> table{ width:400px; height:300px; border:solid 1px blue; border-collapse:collapse; } table td{ text-align:center; } #page { margin-top:10px; } #page a{ text-decoration:none; margin-right:5px; } </style> </head> <body> <center> <table border='1'> <caption><h2>学生信息表</h2></caption> <tr> <th>ID</th> <th>用户名</th> <th>密码</th> <th>年龄</th> </tr> <?php foreach($res as $k => $v) { ?> <tr> <td><?php echo $v['id']?></td> <td><?= $v['username']?></td> <td><?= $v['password']?></td> <td><?= $v['age']?></td> </tr> <?php } ?> </table> <div id='page'> <?= $show; ?> </div> </center> </body> </html>