//CI的分页类,传递的参数是偏移量,
//也就是从库中的第几条记录开始显示,
//而不是某些分页方法中所传递的页码
function show_all($offset)
{
//载入'分页类'
$this->load->library('pagination');
$this->load->helper('form');
$this->load->helper('url');
//根据组合条件,计算记录总数,(当前组合条件为空)
$config['total_rows'] = $this->db->count_all_results('mytable');
//设置本页路径
$config['base_url'] = "本页路径";
//设置每页显示记录数
$config['per_page'] = '15';
//设置分页导航条样式
$config['full_tag_open'] = '<div id = "page_nav">';
$config['full_tag_close'] = '</div>';
$config['first_link'] = '首页';
$config['last_link'] = '末页';
$config['next_link'] = '下一页>';
$config['prev_link'] = '<上一页';
//应用设置
$this->pagination->initialize($config);
//设置查询条件
$this->db->select('你的字段列表');
//排序顺序
$this->db->order_by("id", "desc");
//limit(结果数,偏移量)
$this->db->limit($config['per_page'],$offset);
//查询
$query = $this->db->get('mytable');
//显示结果列表
foreach ($query->result_array() as $row){
$this->table->add_row($row);
}
echo $this->table->generate();
//添加分页导航条
echo $this->pagination->create_links();
}