2013-04-23 53 views
0

嘿,夥計們。我的Codeigniter項目中存在分頁問題。我正在使用分頁庫,並且我有一個搜索表單。當我搜索某些內容時,結果顯示在頁面上。當結果行超過限制時,我會顯示分頁鏈接。但是當我點擊鏈接號碼2進入第二頁時,分頁鏈接消失。我的搜索代碼如下...分頁鏈接在第二頁上消失 - codeigniter

控制器功能:

function search_branch() 
{ 
        $this->load->library('pagination'); 
     $search_this=$this->input->post('inputsearchbranch'); 

     $limit = 20; 
     $data['fields'] = array(
      'branch_name' => 'Branch Name', 
      'city'=>'City', 
      'district'=>'District', 
      'tahsil'=>'Tahsil', 
      'Branch_manager'=>'Branch Manager' 
       ); 

     $this->load->model('mod_user'); 
     $searchbranch=$this->mod_user->search_branch($search_this,$limit); 
     $data['searchbranch'] = $searchbranch; 

     $config = array(); 
     $config['base_url'] = site_url("ctl_home/search_branch/"); 
     $config['total_rows'] = count($searchbranch); 
     $config['per_page'] = $limit; 
     $config['uri_segment'] = 3; 
     $this->pagination->initialize($config); 
     $data['pagination'] = $this->pagination->create_links(); 

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

我的觀點:

<center> 
    <form class="userinfo" action="" method="post"> 
     //table in which search record display 
    </form> 
</center> 
    <?php if (strlen($pagination)): ?> 
<div class="pagination"> 
    <?php echo $pagination; ?> 
</div> 
<?php endif; ?> 
+0

什麼是你的第二個網址頁? – 2013-04-23 04:37:21

+0

@PathikGandhi:'http:// localhost/kccs/index.php/ctl_dbcont/receiptts/receipt_date/asc/20'看起來不對。 。 – Jay 2013-04-23 04:39:03

+0

你可以發佈你的search_branch模型嗎?也許問題出在那裏。 – pat 2013-04-23 07:26:27

回答

0

嘗試改變"$config['uri_segment'] = 3;"$config['uri_segment'] = 5;

而且您正在統計有限記錄的總數。總計數值將計入所有記錄。

0
function search_branch() 
{ 
     $this->load->library('pagination'); 
     $search_this=$this->input->post('inputsearchbranch'); 

     $limit = 20; 
     $data['fields'] = array(
      'branch_name' => 'Branch Name', 
      'city'=>'City', 
      'district'=>'District', 
      'tahsil'=>'Tahsil', 
      'Branch_manager'=>'Branch Manager' 
       ); 

     $this->load->model('mod_user'); 
     $searchbranch=$this->mod_user->search_branch($search_this,false); 
     $config['total_rows'] = count($searchbranch); 

     $searchbranch=$this->mod_user->search_branch($search_this,$limit); 
     $data['searchbranch'] = $searchbranch; 

     $config = array(); 
     $config['base_url'] = site_url("ctl_home/search_branch/"); 

     $config['per_page'] = $limit; 
     $config['uri_segment'] = 3; 
     $this->pagination->initialize($config); 
     $data['pagination'] = $this->pagination->create_links(); 

     $this->load->view('view_searchbranch',$data); 
} 
+0

它不工作。 。 – Jay 2013-04-23 05:23:45

+0

: - 我有其他的函數參數,如$ sort_by ='branch_name',$ sort_order ='asc',$ offset = 0'因此這個過程給數據庫錯誤 – Jay 2013-04-23 05:37:49

+0

只是刪除查詢限制以獲得總數 – 2013-04-23 05:42:20

0

&也使用

$offset = $this->uri->segment(4); 

添加新的參數search_branch功能,並傳遞到數據庫..

$searchbranch=$this->mod_user->search_branch($search_this,$limit,$offset); 

例如函數($其中,$限制,$偏移)

  $this->db->where($where); 
$query = $this->db->get('mytable', $limit, $offset); 
+0

我已經試過了。但不起作用 – Jay 2013-04-23 05:27:08

相關問題