2011-01-27 44 views
0

我有我的工作分頁但隨後數據庫的更改,因此結構現在不工作,因爲我要參加兩個表得到的結果我曾經有過...分頁的笨與加入

我的數據庫腳本是:

$query = $this->db->select('*'); 
$query = $this->db->from('user_entry'); 
$query = $this->db->join('user_details', 'user_entry.UserID = user_details.id'); 
$query = $this->db->limit($limit, $offset); 
$query = $this->db->get(); 

如果你能幫助我,我會很感激 - 謝謝。

+3

您需要給我們更多的信息,你給我們。 「數據庫中的內容是什麼?」。 `什麼不行?` – 2011-01-27 17:22:35

回答

0

我仍然認爲沒有足夠的信息..但分頁需要知道總行才能創建鏈接。假設這個代碼是在你的模型和你打電話從您的控制器模型功能,以設置分頁配置變量:

$this->db->select('*'); 
$this->db->from('user_entry'); 
$this->db->join('user_details', 'user_details.id = user_entry.UserID'); 
$this->db->limit($limit, $offset); 
$query = $this->db->get(); 
return $query->num_rows(); 

在你的控制器:

$config['base_url'] = 'http://yoururl.com/controller/function'; 
$config['total_rows'] = $this->model_name->function(); // Model and function to the code above 
$config['per_page'] = 10; // # of results you want to display per page 
$config['num_links'] = 10; // # of pagination links you want to display 
$this->pagination->initialize($config); 

在你看來,你想顯示分頁:

<?=$this->pagination->create_links();?>