thinkphp自定义分页标签怎么写
1个回答
展开全部
// 用来获取当前用户的买入订单
public function TradingList($p = null) {
$p = intval($p) ? intval($p) : 1;
$pageSize = 15;
$offset = ($p - 1) * $pageSize;
$db = M('rebate_trading');
$TradingList = $db->where(array('userid' => XAAKE))->order('time')->limit($offset, $pageSize)->select();
$count = count($db->where(array('userid' => XAAKE))->select());
$page = new \Think\Page($count, $pageSize);
$page = $page->show();
$this->assign('page', $page);
$this->assign('TradingList', $TradingList);
$this->pagetitle = '已买入订单';
$this->display();
}
上面是没有传递查询参数的如果 你要传递查询参数的话,请看下述代码
// 用来获取搜索字段为field的,当前用户的买入订单
public function TradingList($field = null,$p = null) {
$field ? $where['field'] = array('eq',$field) : '';
$where['userid'] = array('eq',XAAKE);
$p = intval($p) ? intval($p) : 1;
$pageSize = 15;
$offset = ($p - 1) * $pageSize;
$db = M('rebate_trading');
$TradingList = $db->where($where)->order('time')->limit($offset, $pageSize)->select();
$count = count($db->where($where)->select());
$page = new \Think\Page($count, $pageSize);
$page = $page->show();
$this->assign('page', $page);
$this->assign('TradingList', $TradingList);
$this->pagetitle = '已买入订单';
$this->display();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询