Codeigniter分页仅显示选定的最后一页

时间:2018-04-03 12:23:46

标签: codeigniter codeigniter-3

我的网址是:http://[::1]/cashback/index.php/home/brand_offers/3

其中3表示品牌ID

我的控制器:

public function brand_offers($id=null) //getting id of brand from view all offers link in pages
{
    $this->load->library('pagination');
    $config=['base_url'=> base_url('index.php/home/brand_offers'.$id),'per_page'=>2,'total_rows'=>$this->home_offers->total_rows($id)];
    $this->pagination->initialize($config);
    $brand_offers=$this->home_offers->brand_offers($id,$config['per_page'],$this->uri->segment(4));
    $brand_desc=$this->home_offers->brand_desc($id);
    $this->load->view('brand_offers',['offers'=>$brand_offers,'desc'=>$brand_desc]);
}

我的模特:

public function brand_offers($id,$limit,$offset)// get offers according to brand id
{
    $this->db->trans_start();
    $this->db->select('offers.id as oid,offers.offer_type,offers.discount,offers.coupon_code,offers.offer_title,offers.offer_url,offers.offer_desc,brands.brand_logo,brands.bid,brands.brand_desc,brands.brand_banner,brands.brand_url')
            ->from('offers')
            ->join('brands','offers.brand_id=brands.bid')
            ->where('offers.status','0')
            ->where('brands.brand_status','0')
            ->where('offers.brand_id',$id)
            ->order_by('offers.id','DESC')
            ->limit($limit,$offset);
    $q=$this->db->get();
    $this->db->trans_complete();
    return $q->result();
}

在视图中我使用

打印分页
$this->pagination->create_links()

我正在获取链接但是最后一个链接是自动选择的,如果我选择上一个链接,它仍会显示最后一页选择和最后一页数据

0 个答案:

没有答案