PHP code example of zhujinkui / tp5-pages
1. Go to this page and download the library: Download zhujinkui/tp5-pages library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zhujinkui / tp5-pages example snippets
namespace app\index\controller;
use think\Controller;
class Member extends Controller
{
public function index()
{
//$data通过select()查询未分页的数据,不能是已经分页的对象
$data = db('Member')->select();
//参数一:$data未分页的数据,参数二:每页显示的记录数
$p = new \think\Page($data,2);
//把分页后的对象$p渲染到模板
$this->assign([
'p' => $p,
]);
return $this->fetch();
}
}