我的网上商店计划有问题,我想根据品牌名称展示我的所有产品,所以当访客选择其中一个品牌名称时,我会显示产品清单。我成功地在品牌名称上展示了我的产品。我每页设置15个产品。这是工作。但是,虽然我点击第2页,第1页已激活,但产品更改为第2页列表,但页面1中的分页始终处于活动状态。我认为问题出在控制器上,但我不知道究竟是哪里。这是
我的控制器:
function manufacture($manufacturing_name = null,$offset=0)
{
$config['base_url'] = base_url().'listing/manufacture/'.$manufacturing_name;
$config['total_rows'] = $this->m_listing->list_num_rows($manufacturing_name);
$config['per_page'] = 15; /*Jumlah data yang dipanggil perhalaman*/
$config['uri_segment'] = 3; /*data selanjutnya di parse diurisegmen 3*/
/*Class bootstrap pagination yang digunakan*/
$config['full_tag_open'] = "<ul class='pagination pagination-sm' style='position:relative; top:-25px;'>";
$config['full_tag_close'] ="</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";
$this->pagination->initialize($config);
$data['halaman'] = $this->pagination->create_links();
$data['offset'] = $offset;
$data['data'] = $this->m_listing->view($config['per_page'], $offset,$manufacturing_name);
$this->load->view('theme/listing',$data);
}
我的型号:
function list_num_rows($manufacture_name)
{
$this->db->from('product');
$this->db->join('manufacturing','manufacturing.id_manufacturing = product.id_manufacturing','left');
$this->db->where('manufacturing.manufacturing_name',$manufacture_name);
$sql= $this->db->get()->num_rows();
return $sql;
}
function view($num, $offset, $manufacture_name)
{
$this->db->join('manufacturing','manufacturing.id_manufacturing = product.id_manufacturing','left');
$this->db->where('manufacturing.manufacturing_name',$manufacture_name);
$this->db->order_by('launching','desc');
$query = $this->db->get("product",$num, $offset);
return $query->result();
}
我的查看:
<div class="product-listing row">
<?php $no = $offset;
foreach($data as $row ) { ?>
<div class="product__inside__price price-box"><?php echo $row->type ?></div>
<?php } ?>
</div>
<div class="filters-row__pagination">
<?php echo $halaman ?>
</div>
答案 0 :(得分:0)
<强> FYI 强>
这就是我用于分页的内容。
// style
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_link'] = false;
$config['last_link'] = false;
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['prev_link'] = '«';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = '»';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';