后台对应的php代码
//此函数实现数据分页
public function page(){
//limit()方法
/*$user = D('User');
$count = $user->count();//获取总数量
$page = new \Think\Page($count,3);
//实例化分页类,传总数量,和每页应该显示的数量
$page->setConfig('first','首页');
$page->setConfig('last','末页');
$page->setConfig('prev','上一页');
$page->setConfig('next','下一页');
$show = $page->show();//获取分页html样式
$list = $user->limit($page->firstRow,$page->listRows)->select();
$this->assign('list',$list);
$this->assign('page',$show);
$this->display();*/
//page()方法
$user = D('User');
$count = $user->count();
$page = new \Think\Page($count,3);
$list = $user->page(I('get.p'),3)->select();
$page->setConfig('first','首页');
$page->setConfig('last','末页');
$page->setConfig('prev','上一页');
$page->setConfig('next','下一页');
$show = $page->show();
$this->assign('list',$list);
$this->assign('page',$show);
$this->display();
}
而html代码则可以简单的写成一下形式
<!DOCTYPE html>
<html>
<head>
<title>分页显示</title>
</head>
<body>
<form>
<table border='1px'>
<tr><th>id</th><th>user</th><th>email</th></tr>
<foreach name='list' item='obj'>
<tr><td>{$obj.id}</td><td>{$obj.user}</td><td>{$obj.email}</td></tr>
</foreach>
</table>
{$page}
</form>
</body>
</html>
对于html的样式美化,可以在html页面查看源代码,就可以看到相关的class,然后尽情的美化吧