|
楼主 |
发表于 2010-4-6 14:07:19
|
显示全部楼层
本帖最后由 atxlin 于 2010-4-6 14:09 编辑
function page(){
$this->load->library('pagination');
$config['base_url'] = site_url('cate/page');
$sum=$config['total_rows'] = $this->db->count_all('cate');
$per_page=$config['per_page'] = 3;
$config['uri_segment'] = 3;
$this->pagination->initialize($config);
if(($this->uri->segment(3))>0){
$offset=$this->uri->segment(3)+$per_page;
}
else{
$offset=$per_page;
}
if(($sum-$offset) < $per_page){
$per_page=$sum-$offset+$per_page;
}
$data['results'] = $this->mcate->get_books($per_page,$offset);
$this->load->view('cate_show', $data);
}
function get_books($num, $offset) {
$query = $this->db->get('cate', $num, $offset);
return $query;
}
<div>
<ul>
<li class="lis">分类名:</li>
<?php foreach ($content as $res):?>
<li class="lis"><?php echo $res['cate_name'];?>
<a href="<?php echo site_url('cate/getcatebyid/'.$res['id']);?>">修改</a>
<a href="<?php echo site_url('cate/delete/'.$res['id']);?>">删除</a>
</li>
<?php endforeach;?>
</ul>
</div>
<div>
<ul>
<li>
<?php echo $this->pagination->create_links(); ?>
</li>
</ul>
</div> |
|