2011-11-23 4 views
0

사용자의 쿼리를 기반으로 mysql 데이터베이스의 정보를 표시하려고합니다. 양식이 있고 사용자가 데이터를 제출하면 아래에 게시 한 컨트롤러로 이동 한 다음 사용자가 원하는 정보가 표시된보기 파일로 이동합니다.Codeigniter의 페이지 매김이 작동하지 않습니다.

지금까지는이 문제가 좋았지 만 문제는 페이지 매김과 함께 생성됩니다. 현재 데이터베이스에서 표시 할 8 행의 데이터가 있으므로 페이지 설정이 제대로 작동하는지 확인하려면 $ config [ 'per_page'] 값을 5로 설정하십시오 (아래를 확인하십시오). 이제 다음 버튼을 클릭하면 아무 데이터도 표시되지 않습니다.

나는 "다음"버튼을 클릭하면 다시 컨트롤러로 간다.하지만 이번에는 컨트롤러가 사용자가 처음에 게시 한 값을 가져 오지 못한다는 사실에 달려 있다고 생각한다.

친절하게 도와 주시겠습니까? 사전에

감사합니다 :)

내 컨트롤러

: 나는 초기를 복사합니다

function show(){ 

      $batchid=$this->input->post('batchid'); 
      $daterange1=$this->input->post('daterange1'); 
      $daterange2=$this->input->post('daterange2'); 



      $this->load->library('pagination'); 

        $config['base_url'] = base_url().'markslist/show'; 

        $this->db->select('*'); 
         $this->db->from('marks'); 
         $this->db->where('examdate', $daterange1); 
         $this->db->where('examdate', $daterange2); 

         $this->db->join('student', 'marks.studentid = student.studentid'); 
         $this->db->where('batchid', $batchid); 
         $this->db->order_by('batchid','DESC'); 
         $query = $this->db->get(''); 
         $numrows=$query->num_rows(); 

        $config['total_rows'] = $numrows; 
        $config['per_page'] = 5; 
        $config['num_links'] = 20; 
        $config['full_tag_open'] = '<div class="pagination" align="center">'; 
        $config['full_tag_close'] = '</div>'; 

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


      // To get the subject lists 
      $this->load->model('mod_markslist'); 
      $data['records']= $this->mod_markslist->listmarks($batchid,$daterange1,$daterange2,$config['per_page'],$this->uri->segment(3)); 



      $data['main_content']='view_markslist'; 
      $this->load->view('includes/template',$data); 

    } 

답변

1

세션에 데이터를 게시 :

if($this->input->post()){ 
    $this->session->set_userdata('batchid', $this->input->post('batchid')); 
    $batchid = $this->input->post('batchid'); 
    /* similar for the other posted fields */ 
} 
else{ 
    $batchid = $this->session->userdata('batchid'); 
    /* similar for other fields now in session */ 
} 
/* load pagination library etc */ 

베스트 정보는 또한 검사 작업을 수행하는 경우 세션에서도 사용할 수 있습니다.

+0

고맙습니다. –

관련 문제