簡體   English   中英

為什么我的分頁代碼不起作用

[英]why my pagination code is not working

這是我的分頁功能,在其下編寫分頁代碼,我在其他if部分中的另一個函數login_process中調用了此分頁功能(abc(offset = 0)),並將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(); ?>

請檢查我做錯了..

我有一個類似的問題,當我在我的appplication / config / routes.php文件中將路徑添加到控制器功能時,問題就解決了
類似於:

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

自定義它。 希望對您有幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM