我是Codeigniter的新手。我正在codeigniter中创建分页,但是分页号不起作用。
这是我想要分页的记录
当我单击分页链接时,出现此类型错误。
这是我的控制器代码
public function benadharStatus($rowno=0) {
$this->load->library("pagination");
if ($this->session->userdata('session_name')) {
$data = array();
$data = array('title' => 'Beneficiaries Aadhaar Status', 'pageTitle' => 'Beneficiaries Aadhaar Status');
$obj = new Admin_model;
$obj1 = new Reporting_model;
$data['states'] = $obj->getState();
if($_POST){
// Row per page
$rowperpage = 25;
// Row position
if($rowno != 0){
$rowno = ($rowno-1) * $rowperpage;
}
// All records count
$allcount = $obj1->getBenficzReportOLD($_POST);
// Get records
$users_record = $obj1->getBenficzReports($_POST,'1',$rowno,$rowperpage);
// Pagination Configuration
$config['base_url'] = base_url().'benadharStatus';
$config['use_page_numbers'] = TRUE;
$config['total_rows'] = $allcount;
$config['per_page'] = $rowperpage;
$config['uri_segment'] = 5;
// Initialize
$this->pagination->initialize($config);
$data['links'] = $this->pagination->create_links();
$data['benficirz'] = $users_record;
$data['row'] = $rowno;
$data['passed_state']=$this->input->post('ben_state');
$data['passed_district']=$this->input->post('ben_district');
$data['passed_awc']=$this->input->post('ben_awc');
$data['flag']=1;
}else{
$data['flag']=2;
}
$this->load->view('reports/benadharStatus', $data);
} else {
redirect('admin');
}
}
请大家帮忙...预先感谢
答案 0 :(得分:2)
请尝试使用此代码替换此代码:
public function benadharStatus($rowno=0) {
$this->load->library("pagination");
if ($this->session->userdata('session_name')) {
$data = array();
$data = array('title' => 'Beneficiaries Aadhaar Status', 'pageTitle' => 'Beneficiaries Aadhaar Status');
$obj = new Admin_model;
$obj1 = new Reporting_model;
$data['states'] = $obj->getState();
if($_POST){
// Row per page
$rowperpage = 25;
// Row position
if($rowno != 0){
$rowno = ($rowno-1) * $rowperpage;
}
// All records count
$allcount = $obj1->getBenficzReportOLD($_POST);
// Get records
$users_record = $obj1->getBenficzReports($_POST,'1',$rowno,$rowperpage);
// Pagination Configuration
$controler_name = $this->router->fetch_class();
$config['base_url'] = base_url().'/'.$controler_name.'/benadharStatus';
$config['use_page_numbers'] = TRUE;
$config['total_rows'] = $allcount;
$config['per_page'] = $rowperpage;
$config['uri_segment'] = 5;
// Initialize
$this->pagination->initialize($config);
$data['links'] = $this->pagination->create_links();
$data['benficirz'] = $users_record;
$data['row'] = $rowno;
$data['passed_state']=$this->input->post('ben_state');
$data['passed_district']=$this->input->post('ben_district');
$data['passed_awc']=$this->input->post('ben_awc');
$data['flag']=1;
}else{
$data['flag']=2;
}
$this->load->view('reports/benadharStatus', $data);
} else {
redirect('admin');
}
}