2011-11-28 2 views
1

데이터베이스에서 정보를 표시하려고합니다. $ config [ 'per_page']를 2로 설정했는데, 내 뷰 파일에서 원하는 정보를 볼 수 있지만 다음 버튼을 클릭해도 아무 것도 바뀌지 않습니다. 데이터베이스 값은 동일하게 유지되며 현재 페이지도 첫 번째 페이지로 유지됩니다.Codeigniter Paginaton 다음 단추가 작동하지 않습니다.

문제를 해결하는 데 도움을 주시기 바랍니다. 사전에

감사합니다 :)

컨트롤러 :

function index($id){     
    $this->load->library('pagination');         
    $config['base_url'] = site_url().'Student_fee_status/index/'.$id; 

    $this->db->select('*'); 
    $this->db->from('studentpayment1'); 
    $this->db->where('studentid', $id); 

    $query = $this->db->get(''); 
    $numrows=$query->num_rows();      

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

    $this->pagination->initialize($config);     
    $this->load->model('Mod_student_fee_status'); 

    $data['records']= $this->Mod_student_fee_status->fee_status($id,$config['per_page'],$config['uri_segment']); 
    $data['main_content']='view_student_fee_status'; 

    $this->load->view('includes/template',$data);     
} 

내 모델 :

function fee_status($id,$perPage,$uri_segment) { 
    $this->db->select('*'); 
    $this->db->from('studentpayment1'); 
    $this->db->where('studentid', $id); 

    $getData = $this->db->get('', $perPage, $uri_segment); 

    if($getData->num_rows() > 0) 
     return $getData->result_array(); 
    else 
     return null; 
} 

편집

페이지가 처음로드 링크는 this- http://localhost/sundial/Student_fee_status/index/1006/ 처럼 보이는 경우 하지만 다음 페이지를 클릭하면 다음과 같이 보입니다.,517,724,885,923,183,210

내 파일보기 :

<h1>Payment Status</h1>  
<?php if(count($records) > 0) { ?> 
    <table id="table1" class="gtable sortable"> 
     <thead> 
      <tr> 
       <th>S.N</th> 
       <th>Invoice ID</th> 
       <th>Transaction Description</th> 
       <th>Received Date</th> 
       <th>Debit</th> 
       <th>Credit</th> 
       <th>Balance</th> 
      </tr> 
     </thead> 

    <?php $i = $this->uri->segment(2) + 0; foreach ($records as $row){ $i++; ?> 
     <tbody> 
      <?php 
       $mydate= $row['period']; 
       $month = date("F",strtotime($mydate)); 
       $year = date("Y",strtotime($mydate)); 
      ?> 
      <tr> 
       <td><?php echo $i; ?>.</td> 
       <td><?php echo $row['invoiceid'];?></td> 
       <td><a href="<?php echo base_url(); ?>student_fee_status/fee_types/<?php echo $row['paymentid']; ?>" rel="1" class="newWindow" >Total Fee For <?php echo $month ;?>, <?php echo $year ;?> </a></td> 
       <td><?php echo $row['received_date'];?></td> 
       <td><?php echo $row['totalamount'];?></td> 
       <td><?php echo "0";?></td> 
       <td><?php echo $row['totalamount'];?></td> 
      </tr> 
      <tr> 
       <td><?php echo $i; ?>.</td> 
       <td><?php echo $row['invoiceid'];?></td> 
       <td>Payment Received </td> 
       <td><?php echo $row['received_date'];?></td> 
       <td><?php echo "0";?></td> 
       <td><?php echo $row['amountpaid'];?></td> 
       <td> 
        <?php 
         $balance=$row['totalamount']-$row['amountpaid']; 
         if($balance>0){ 
          echo "<font color=\"red\">$balance</font>"; 
         } 
         else { 
          echo $balance; 
         } 
        ?> 
       </td> 
      </tr> 
    <?php } ?> 
     </tbody> 
    </table> 
<?php } ?> 

<div class="tablefooter clearfix"> 
    <div class="pagination"> 
     <?php echo $this->pagination->create_links(); ?> 
    </div>        
</div> 
+0

것 같은 링크를 보입니까? – applechief

+0

보기의 관련 부분도 함께 추가하십시오. –

+0

답장을 보내 주셔서 감사합니다. 샤프트와 구스타프 버트 람. 위의 내 게시물의 수정 된 부분을 확인하십시오. –

답변

4

당신은 $config['uri_segment'] = '2'; 사용하도록 매김 라이브러리를 말하고있다 - 당신의 URI의 두 번째 세그먼트를. 이 귀하의 URL을 때

: 나는 추측하고 http://localhost/sundial/Student_fee_status/index/1006/이 당신의 BASE_URL입니다 : 당신의 세그먼트는이 경우 http://localhost/sundial/

있습니다

  1. Student_fee_status - 컨트롤러
  2. 인덱스 - 컨트롤러 방법 당신 호출하고 있습니다
  3. 1006 - 컨트롤러 메소드를 호출하는 인수
  4. 이것은 인수 f 여야합니다.

    $data['records']= $this->Mod_student_fee_status->fee_status($id,$config['per_page'],$config['uri_segment']); 
    
    : 또는 매김

$config['uri_segment'] = '4';

대신

$config['uri_segment'] = '2';

편집의 시도

이 줄에는 다른 오류가 있다고 생각합니다.

페이지 네이션 라이브러리가 uri_segment를 사용하는 정보를 모델에 전달합니다. 이제 4 살이 돼야합니다. 그러나 모델에서는이 값을 사용하여 쿼리에서 오프셋을 지정합니다. 즉, 항상 4라는 오프셋을 쿼리에 넣습니다. 하지만 실제로하고 싶은 것은 4 번째 uri_segment의 VALUE 모델을 전달하는 것입니다. 내가 대신 이것을 시도 할

:

$data['records']= $this->Mod_student_fee_status->fee_status($id,$config['per_page'],$this->uri->segment($config['uri_segment'])); 
+0

미안 walfish3d 귀하의 제안이 저에게 효과적이라고 생각했지만 잠시 후 다음 버튼이 작동하지만 첫 번째 페이지의 데이터베이스 값이 변하지 않았다고 생각했습니다. 내 코드에 어떤 문제가 있는지 알고 계신가요? 미리 감사드립니다 :) –

+0

내 대답을 편집했습니다. 도움이되기를 바랍니다. – mwallisch

+0

대단히 감사합니다 walfish3d. 내가 원하는 방식으로 작동합니다. 나는 이것을 이틀 동안 고치려고 노력해왔다. 당신은 위대한 사람입니다 ... :) –

관련 문제