2014-09-02 40 views
0

我的控制器:笨:分頁沒有得到其他行

$config['base_url'] = base_url('admin/profile?id=' . $profile_id); 
    $config['total_rows'] = 1000;//count($data['getTime']); 
    $config['per_page'] = 5; 
    $config['num_links'] = 2; 
    //$config['uri_segment'] = 2; 
    //$config['enable_query_strings'] = TRUE; 
    $config['page_query_string'] = TRUE; 
    $config['use_page_numbers'] = TRUE; 
    $config['full_tag_open'] = '<div id="pagination">'; 
    $config['full_tag_close'] = '</div>'; 

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

    $page = ($this->uri->segment(5))? $this->uri->segment(5) : 0; 
    $data['getTime'] = $this->admin->getUserProfileTime($profile_id, $config["per_page"], $page); 
    $data["links"] = $this->pagination->create_links(); 
    //pagination 

我的模型

function getUserProfileTime($profile_id, $num, $page) 
{ 
$this -> db -> select('*'); 
//$this -> db -> from('timerecord'); 
$this -> db -> where('id', $profile_id); 
//-$this -> db -> order_by('dateToday', 'DESC'); 
$this -> db -> order_by('dateOrder', 'DESC'); 
$this -> db -> limit($num, $page); 

$query = $this -> db -> get('timerecord'); 
//$array = $query->result_array(); 
return $query->result(); 

if ($query->num_rows() > 0) { 
     foreach ($query->result() as $row) { 
      $data[] = $row; 
     } 
     return $data; 
    } 
    return false; 

}

我的看法

<?php 
       foreach($getTime as $row): 
       $timeStat = $row->status; 
       $approveStat = $row->ApprovalStat; 
       ?> 
       <tr> 
       <td class="tn-ixdt"><?php echo $row->year_Int ?></td> 
       <td class="tn-ixdt"><?php echo $row->dateToday ?></td> 
       <td class="tn-ixdt"><?php echo $row->day ?></td> 
       <td class="tn-ixdt" style="text-align:center;"><?php echo $row->day_Int ?></td> 
       <td class="tn-ixdt"><?php echo $row->timeIn ?></td> 
       <td class="tn-ixdt"><?php echo $row->timeOut ?></td> 
       <td class="tn-ixdt"><?php echo $row->status ?></td> 
       </tr> 
       <?php endforeach; ?> 
       </table><br /> 
      <div align="center"><?php echo $links; ?></div> 

您好,我的分頁工作不正常,它顯示第一個5正確的記錄,但是當我點擊分頁鏈接它不會去其他行,這是問題是在我的網址查詢?我的網址就像這個admin/profile?id = 1 & per_page = 65,頁碼也是正確的,但它仍然沒有從我的表中獲取其他記錄。拜託,我需要你的幫助!謝謝!

+0

嘗試打印當您打開下一頁時生成的原始查詢,請參閱wht's wro那裏 – ngakak 2014-09-02 08:44:52

+0

你是什麼意思原始查詢建立?先生。 ngakak? – CyrussDev 2014-09-02 09:26:39

+0

原始查詢導致您的活動記錄 – ngakak 2014-09-02 09:44:03

回答

0

,因爲使用錯誤的表你..嘗試將它添加到您的控制器

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

,並在你看來,看你表..這裏是代碼

$this->table->set_heading('header1', 'header2', 'header3','header4'); //this is just the table heading 

//in this code, you are looping your table row and the database informatio 
    foreach ($products->result() as $row) { 


     $this->table->add_row(
      $row->column1, 
      $row->column2, 
      $row->column3, 
      $row->column4 
     ); 
    } 


    echo $this->table->generate(); 

和驗證碼請刪除 - > result(),它應該是

foreach ($query as $row) { 
     $data[] = $row; 
    } 
+0

仍然不幸運先生。codeslayer,這裏是輸出 <1 2 3 頭1 \t \t HEADER2 header3 \t header4 2014年9月1日星期一\t \t上午09時21 2014年9月1日星期一\t \t上午09時21 2014年9月1日\t週一\t上午9時21分 2014年9月1日\t週一\t上午9時21分 2014年9月1日\t週一\t 9:21 am <1 2 3 – CyrussDev 2014-09-02 09:08:08

+0

即使在第3頁上顯示的輸出結果顯示 – CyrussDev 2014-09-02 09:08:44

+0

不要把這個輸出放在這裏..編輯你的答案並在完成編輯後添加輸出和註釋以通知我 – CodeSlayer 2014-09-03 02:46:17