0

我使用 codeigniter 分页类对我的记录进行分页,下面你可以看到我的代码

$data['success'] = "";
  $data['error'] = "";
  $data['offset'] = 0;

  $this->load->library('pagination');
  $per_page = 4;
  $total = $this->m_workshop->totalworkshoppay();
  $baseUrl = site_url('sitemanager/workshop/workshopayment');
  $data['query'] = $this->m_workshop->getallwpay($per_page, (int) $this->uri->segment(4));     
  $confignew['base_url'] = $baseUrl;
  $confignew['total_rows'] = $total;
  $confignew['per_page'] = $per_page;
  $confignew['uri_segment'] = '4';
  $this->pagination->initialize($confignew);


  $data['offset'] = (int) $this->uri->segment(4);
  $this->load->view('sitemanager/workshop/viewallworkshoppay',$data);

我在我的视图页面中使用<?php echo $this->pagination->create_links(); ?> 代码来显示分页链接。但是分页链接没有显示在浏览器中。当我打印 $data['query']时,记录会根据变量进行限制 $per_page

4

1 回答 1

1

首先在控制器中创建链接。您还必须确保获取足够的记录来建立链接。我通常在第一次设置时将每页设置为 1 以确保它正常工作。

控制器:

  $data['success'] = "";
  $data['error'] = "";
  $data['offset'] = 0;

  $this->load->library('pagination');
  $per_page = 4;
  $total = $this->m_workshop->totalworkshoppay();
  $baseUrl = site_url('sitemanager/workshop/workshopayment');
  $data['query'] = $this->m_workshop->getallwpay($per_page, (int) $this->uri->segment(4));     
  $confignew['base_url'] = $baseUrl;
  $confignew['total_rows'] = $total;
  $confignew['per_page'] = $per_page;
  $confignew['uri_segment'] = '4';
  $this->pagination->initialize($confignew);
  $data['pages'] = $this->pagination->create_links();


  $data['offset'] = (int) $this->uri->segment(4);
  $this->load->view('sitemanager/workshop/viewallworkshoppay',$data);

看法:

echo $pages;
于 2013-04-15T11:26:58.787 回答