Codeigniter에서 페이지 매김 라이브러리를 사용하여 데이터 테이블에 적절한 페이지 매김을 제공하는 방법

안킷 수 타르

CodeIgniter에서 페이지 매김 작업 중입니다. 튜토리얼과 사용 설명서도 봅니다. 하지만 제대로 수행하는 방법을 찾을 수 없습니다. 그들은 페이지 매김을 위해 Controller에서 데이터베이스를 호출합니다. 적절한 해결책을 원합니다.

이것은 컨트롤러입니다

    public function index() {

                $this->load->library('pagination');
                $config['base_url'] = 'index.php/Emp';
                $config['total_rows'] = 200;
                $config['per_page'] = 2; 
                $config['uri_segment'] = 3;

                $this->pagination->initialize($config); 


        $data = array(); 

        $data['showEmployeeTable']=$this->Em->selectEmployeeData(); //FOR SHOWING A EMPLOYEE DATABASE TABLE

        if($query = $this->Em->getDesignationData())  //grabs all record
        {
            $data['records'] = $query;
        }

        if($query = $this->Em->getCityRecord())  //grabs all record
        {
            $data['records_city'] = $query;
        }

        //$this->load->view('emp_update', $data);
        $this->load->view('erv', $data);

    }

이것은 내 모델입니다

public function getDesignationData() {

    $query = $this->db->get('emp_desig'); //model created for get data 
    return $query->result();
}


public function getCityRecord() {

    $query = $this->db->get('city'); //model created for get data 
    return $query->result();
}

// ***************** VEDDING PLAN MODELS **********************************************************


public function selectEmployeeData() {  

     $query = $this->db->get('emp_manage');  
     return $query;  
} 

그렇다면보기 페이지에 적절한 페이지 매김을 어떻게 표시 할 수 있습니까? 단계별로 친절하게 대답 해주십시오. 저는 Codeigniter의 초보자입니다.

그리고 이것은보기에서.

<?php echo $this->pagination->create_links(); ?>
헤마 찬드라

컨트롤러는

public function index() {

    $this->load->library('pagination');
    $config = array();
    $config['base_url'] = 'index.php/Emp';
    $config['total_rows'] = 200;
    $config['per_page'] = 2;
    $config['uri_segment'] = 3;
    $this->pagination->initialize($config);


    $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
    $data['showEmployeeTable']=$this->Em->selectEmployeeData($config["per_page"], $page);
    $data["links"] = $this->pagination->create_links();


    if($query = $this->Em->getDesignationData())  //grabs all record
    {
        $data['records'] = $query;
    }

    if($query = $this->Em->getCityRecord())  //grabs all record
    {
        $data['records_city'] = $query;
    }

      $this->load->view('erv', $data);

}

모델은

public function selectEmployeeData($limit, $start) {  

 $this->db->limit($limit, $start);
     $query = $this->db->get('emp_manage');  
     return $query;  
} 

그리고 당신의 뷰에서 다음 줄을 추가하십시오

<?php echo $links; ?>

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관