2013-12-18 2 views
0

기본적으로 Codeigniter로 부트 스트랩 테마를 사용하고 있습니다.Codeigniter : 테이블 라이브러리를 사용하지 않고 페이지 매기기 데이터

여기 내 컨트롤러 코드입니다. 교사는 데이터베이스의 테이블입니다.

public function index() { 
    $this->load->library('pagination'); 

    $config['base_url'] = 'http://localhost:8888/bootstrap/index.php/frontpage/index'; 
    $config['total_rows'] = $this->db->get('tutors')->num_rows(); 
    $config['per_page'] = 6; 
    $config['num_links'] = 10; 

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

    $data['records'] = $this->db->get('tutors', $config['per_page'], $this->uri->segment(3)); 

    $this->load->view('include/header'); 
    $this->load->view('frontpage', $data); 
    $this->load->view('include/footer'); 
} 

나는 다음과

<div class="container" style="text-align: center;"> 

    <?php 
     $i=0; 

     foreach($records as $row) : 
      if ($i%3==0) { ?> 
       <div class="row"> 
        <div class="col-md-4"> 
         <h1><?php echo $row->title; ?></h1> 
         <h2><?php echo $row->id; ?></h2> 
        </div> 
      <?php 
      } else { 
      ?> 
       <div class="col-md-4"> 
        <h1><?php echo $row->title; ?></h1> 
        <h2><?php echo $row->id; ?></h2> 
       </div> 
       <?php 
       if ($i%3==2) { 
        echo "</div>"; 
       } 
      } 

      $i++; 
     endforeach; 
    ?> 
</div> 

<div class="container"> 
    <?php echo $this->pagination->create_links(); ?> 
</div> 

로보기를 사용자 정의 할 수 그러나 그것은 오류를 가져옵니다. 어떻게 수정할 수 있습니까? 감사합니다.

+1

이 오류가 무엇입니까 ($ $ 행으로 기록)를 사용하려고? –

+0

PHP 오류가 발생했습니다. 심각도 : 알림 메시지 : 비 객체의 속성을 얻으려고 시도합니다. 파일 이름 : views/frontpage.php – Barry

+0

오, 변수 $ 행 선언을 놓쳤습니까? – Barry

답변

0

는 ($ 행으로 $ 질의 -> 결과())

foreach는 대신 foreach는의

관련 문제