这是我业务方面的一些代码分享给大家:
这里是controller里面的两个方法:
//分页设置
function page_config($count, $add) {
$config ['base_url'] = $add; //设置基地址
$config ['uri_segment'] = 3; //设置url上第几段用于传递分页器的偏移量
$config ['total_rows'] = $count;
$config ['per_page'] = 10; //每页显示的数据数量
//$config ['first_link'] = '首页';
//$config ['last_link'] = '末页';
$config ['next_link'] = '下一页>';
$config ['prev_link'] = '<上一页';
return $config;
} //业务签单列表
function market_list() {
$data ['action_market'] = $this->user_action()->action_market;
$this->session ();
$add = 'market/market_list';
$count = $this->db->count_all ( 'market_sig' ); //取数量
$config = $this->page_config ( $count, $add );
$this->pagination->initialize ( $config ); //设置完成分页器
$this->load->library ( 'table' ); //加载表格类
$data ['list'] = $this->Mmarket->market_sig ( $config ['per_page'], $this->uri->segment ( 3 ) ); //这里看market的model类
$this->load->view ( 'market/market_list', $data );
}
下面是model类里面的方法:
//列表
function market_sig($n,$o) {
if($o==''){$o=0;}
$result = $this->db->query ( "select * from market_sig where del!=0 order by sig_time desc limit $o,$n" );
$re = $result->result ();
return $re;
}
view里面只要这样写就可以了:
pagination->create_links(); ?>
代码供您参考,有什么问题欢迎联系我。