1
我有分頁類笨 這裏的一個小問題是我的控制器分頁使用笨
function index()
{
$this->load->library('pagination');
$config['base_url'] = base_url().'index.php/books/index/';
$config['total_rows'] = $this->db->count_all('books');
$config['per_page'] = '5';
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
$this->pagination->initialize($config);
echo "Here";
//load the model and get results
$this->load->model('books_model');
$data['results'] = $this->books_model->get_books($config['per_page'],$this->uri->segment(3));
// load the HTML Table Class
$this->load->library('table');
$this->table->set_heading('Title');
// load the view
$this->load->view('books_view', $data);
}
,這裏是視圖
<body>
<h1>Books</h1>
<?php echo $this->table->generate($results); ?>
<?php echo $this->pagination->create_links(); ?>
</body>
和模型
function get_books($num, $offset) {
$query = $this->db->get('books', $num, $offset);
return $query;
}
我設置了我的數據庫,並且已經路由(default-> books),但是頁面沒有顯示出來nything。我的數據庫表是書。
你確定你從數據庫中獲得結果嗎?如果你沒有得到任何結果,分頁不會顯示 – Henesnarfel 2012-02-13 14:24:11