Php 为什么我的分页代码不起作用

Php 为什么我的分页代码不起作用,php,codeigniter,pagination,Php,Codeigniter,Pagination,这是我的分页函数,分页代码是在该函数下编写的,我在else if部分的另一个函数login_进程中调用了该分页函数(abc(offset=0)),并将abc函数值传递给函数login_进程内的view admin_视图,在我的login_视图中,我使用了分页代码,在该视图中,获取的数据以分页方式显示,但当我单击链接12或出现任何错误时,在该服务器上找不到请求的URL/terse/welcome/abc/1。并且没有执行分页 我的分页功能代码: public function abc($offse

这是我的分页函数,分页代码是在该函数下编写的,我在else if部分的另一个函数login_进程中调用了该分页函数(abc(offset=0)),并将abc函数值传递给函数login_进程内的view admin_视图,在我的login_视图中,我使用了分页代码,在该视图中,获取的数据以分页方式显示,但当我单击链接12或出现任何错误时,在该服务器上找不到请求的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_进程函数,在该函数中我调用了abc并将其值传递给admin_视图(仅查看其elseif部分)

公共功能登录\u过程()
{
$this->load->model('insert_model');
$data['users']=数组(
“fname”=>this->input->post('fname'),
'pass'=>this->input->post('pass'),
); 
$status=$this->insert\u model->login\u test($data);
$st['ss']=$this->insert_model->stat($data);
//打印“”;打印($status);死亡();
  echo $this->table->generate($books); ?>
    <?php echo $this->pagination->create_links(); ?>
如果($status==true&&$st['ss'][0]['status']==0) { $ses=数组( '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\u view',$im); $this->load->view('navside_view'); $this->load->view('user_view'); } elseif($status==true&&$st['ss']['0']['status']==1) { $ses=数组( 'username'=>this->input->post('fname'), 'password'=>this->input->post('pass'), ); $this->session->set_userdata($ses); $im['pic']=$this->insert_model->image_fetc(); //打印($aaa);模具(); //$data['aa']=“sd”; $data['books']=$this->abc(); $this->load->view('header\u view',$im); $this->load->view('navside_view'); $this->load->view('admin_view',$data); } 其他的 { $this->load->view('header_view'); $this->load->view('navside_view'); $this->load->view('center\u view\u login'); } }
我的管理员视图代码
echo$this->table->generate($books);?>

请检查我做错了什么。

我遇到了类似的问题,当我在appapplication/config/routes.php文件中添加控制器函数的路径时,问题得到了解决
类似于:

$route['terse/welcome/abc/(:num)]='terse/welcome/abc';

定制它。希望它能帮助你。

没有人能代替$data['books']=$this->db->get('register',5,$offset)解决这个问题;尝试:函数fetch_books($offset){$this->db->limit(5,$offset);$query=$this->db->get(“register”);if($query->num_rows()>0){foreach($query->result()as$row){$data[]=$row;}返回$data;}返回false;}$data['books']=获取_books($offset);
  echo $this->table->generate($books); ?>
    <?php echo $this->pagination->create_links(); ?>