这是我的分页函数,在该函数下编写分页代码,我在另一个函数login_process中调用了这个分页函数(abc(offset = 0)),如果是part,则传递abc函数值来查看函数login_process中的admin_view并且在我的login_view中,我使用了分页代码,并且已经使用分页显示了获取的数据,但是当我单击链接1 2或任何随后出现错误时在此服务器上找不到请求的URL / terse / welcome / abc / 1。分页不是很重要的 我的分页功能代码:
public function abc($offset = 0){
$this->load->model('insert_model');
//$data ['query'] = $this->insert_model->view_data();
$this->load->library('table');
// Load Pagination
$this->load->library('pagination');
// Config setup
$config['base_url'] = base_url().'/welcome/abc';
$items= $config['total_rows'] = 20;
$perpage=$config['per_page'] = 1;
// I added this extra one to control the number of links to show up at each page.
$config['num_links'] = 5;
// Initialize
$this->pagination->initialize($config);
// Query the database and get results
// Here we add the limit and the offset
// The second parameter is the limit, since we are showing
// 10 per page, the limit should be 10
$data['books'] = $this->db->get('register',5, $offset);
// Create custom headers
$header = array('id','username','lastname','email' , 'password', 'image','status');
// Set the headings
$this->table->set_heading($header);
// Load the view and send the results
return $data['books'];
}
我的login_process函数,其中我调用了abc并将其值传递给admin_view(仅查看其elseif部分)
public function login_process()
{
$this->load->model('insert_model');
$data['users'] = array(
'fname' => $this->input->post('fname'),
'pass'=> $this->input->post('pass'),
);
$status= $this->insert_model->login_test($data);
$st['ss']=$this->insert_model->stat($data);
//print "<pre>"; print_r($status); die();
if($status == true && $st['ss'] [0] ['status'] == 0)
{
$ses = array(
'username' => $this->input->post('fname'),
'password' => $this->input->post('pass'),
);
$this->session->set_userdata($ses);
$im['pic']=$this->insert_model->image_fetc();
$this->load->view('header_view',$im);
$this->load->view('navside_view');
$this->load->view('user_view');
}
elseif($status == true && $st['ss']['0'] ['status'] == 1)
{
$ses = array(
'username' => $this->input->post('fname'),
'password' => $this->input->post('pass'),
);
$this->session->set_userdata($ses);
$im['pic']=$this->insert_model->image_fetc();
// print_r($aaa); die();
// $data['aa'] = "sd";
$data['books'] = $this->abc();
$this->load->view('header_view',$im);
$this->load->view('navside_view');
$this->load->view('admin_view', $data);
}
else
{
$this->load->view('header_view');
$this->load->view('navside_view');
$this->load->view('center_view_login');
}
}
我的admin_view代码
echo $this->table->generate($books); ?>
<?php echo $this->pagination->create_links(); ?>
请检查我做错了什么..
答案 0 :(得分:0)
我遇到了类似的问题,当我在appplication / config / routes.php文件中添加控制器功能的路径时解决了这个问题
类似的东西:
$route['terse/welcome/abc/(:num)'] = 'terse/welcome/abc';
自定义它。希望它可以帮到你。