2011-08-15 4 views
1

codeigniterとそれにはクラス(library) paginationが使用されています。
このコードは次のように、ページ付けにcounting rowsために機能しない理由:ページングの行数をカウントして表示しますか?

既存の行:4 - > 1 9

又は

既存の行の4までを示します。 4 - > 9の4から8を表示

または

既存の行:1 - >他の


$this->load->library('pagination'); 
    //$this->load->library('Jquery_pagination'); 
    $config['base_url'] = base_url().'admin/accommodation/show'; 
    $config['uri_segment'] = 4; 
    $config['total_rows'] = $this->db->count_all('hotel_submits'); 
    $config['per_page'] = '4'; 
    //$config['div'] = '#num_count'; /* Here #content is the CSS selector for target DIV */ 
    $config['num_links'] = 10000; 
    $config['full_tag_open'] = '<div id="pagination">'; 
    $config['full_tag_close'] = '</div>'; 

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

    $offset = (int) $offset; // just to make sure nothing funky gets in here 
    $data['results'] = $this->db->query("SELECT @rownum:[email protected]+1 rownum, t.* 
    FROM (
     SELECT * 
     FROM hotel_submits 
     ORDER BY id desc 
     LIMIT $offset, 4  
    ) t, 
    (SELECT @rownum:=0) r"); 

///////////////////////////////////////////////////////////////// 

$curr_offset = $this->uri->segment($config['uri_segment']); 
     $info = 'Showing ' . ($curr_offset + 1) . ' to ' ; 

     if(($curr_offset + $config['per_page']) < ($config['total_rows'] -1)) 
      $info = $curr_offset + $config['per_page']; 
     else 
      $info = $config['total_rows']; 

     $info = ' of ' . $config['total_rows'] . ' | '; 

     $data['num_count'] = $info; 

///////////////////////////////////////////////////////////////// 

$this->load->view('admin/accommodation_submit_show', $data); 

出力9

9に8を表示このコードは:of 9 |複数の場所で

答えて

1

$info .= 
    ^
+0

感謝し、新しい問題、なぜそれぞれの後に、列 '#'で改ページをクリックしてください最初から行をカウントすること。私はこれが欲しい(p =ページネーション): 'p1-># - > 1 2 3 | p2→#→4 5 6 | p3 - ># - > 7 8 9 | p4# - > 10 '? 'トップコードの結果(rownum)変数はこれに関連しています。] ** **例:** [私の問題の例を参照](http://www.binboy.gigfa.com/admin/hotel/show/ )。あなたはこの問題を解決する方法を知っていますか? ] –

関連する問題