|
分页出了问题,不知道如何解决,看看图,一定要帮帮我,菜鸟等回
控制器的代码:
$this->load->library('pagination');
$header['he1']=$this->Mhome->category();
$this->load->view('top',$header);
$config['base_url'] = base_url().'index.php/welcome/category/'.$this->uri->segment(3).'/';
$config['total_rows'] = $this->Mhome->get_category_count($this->uri->segment(3));
$config['per_page'] = '6';
$config['page_query_string'] = TRUE;
$this->pagination->initialize($config);
$data['con']=$this->Mhome->get_category_c($this->uri->segment(3),$config['per_page'],$this->uri->segment(4));
$this->load->view('category',$data);
$this->load->view('bottom');
模型代码:
function get_category_count($id)
{
$query = $this->db->query("select * from `product` where category=$id");
return $query->num_rows();
}
function get_category_c($id,$offset,$pagesize)
{
$query = $this->db->get_where('product',array('category'=>$id),$offset,$pagesize);
return $query->result();
}
视图代码:
<?foreach ($con as $row):?>
<table>
<tr><td><img src="<?=base_url().$row->img?>" alt="<?=$row->name?>" /></td></tr>
<tr><td><?=anchor('welcome/show/'.$row->id,$row->name)?></td></tr>
<tr><td><p><?=anchor('welcome/show/'.$row->id,'VIEW')?></p></td></tr>
</table>
<?endforeach;?>
<?=$this->pagination->create_links();?> |
-
|