我需要幫助,我的代碼點火器app..i似乎無法找出是什麼導致分頁不工作笨:分頁+表庫(沒有工作)
這裏是我的控制器
$limit = 15;
$uri_segment = 4;
$this->load->helper('string');
$offset = $this->uri->segment($uri_segment);
log_message('error',date('Y-m-d H:i:s', time()));
//load
//$products = $this->Products_model->get_all();
$products = $this->Products_model->get_products($limit, $uri_segment);
//var_dump($products);
log_message('error', $products);
//pagination
$this->load->library('pagination');
$config['base_url'] = site_url('admin/products/index/');
$config['total_rows'] = $this->Products_model->count_all();
$config['per_page'] = $limit;
$config['uri_segment'] = $uri_segment;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
//table
$this->load->library('table');
$this->table->set_empty(" ");
$this->table->set_heading('ID', 'Product','Category', 'Actions');
$i = 0 + $offset;
foreach ($products as $product){
++$i;
$this->table->add_row($product->id, $product->title, $this->Categories_model->get_by_id($product->category_id)->title,
anchor('/admin/products/update/'.$product->id,'update',array('class'=>'update')).' '.
anchor('/admin/products/delete/'.$product->id,'delete',array('class'=>'delete','onclick'=>"return confirm('Are you sure want to delete this product?')"))
);
}
$data['table'] = $this->table->generate();
//load template
$this->products_list();
$this->products_template();
$this->template->build('products/productList', $data);
這裏是我的模型
function get_products($num, $offset) {
return $this->db->get($this->tbl_products, $num, $offset)->result();
}
它生成的鏈接,但那麼它不會加載下一組記錄..任何更正上面的代碼?
謝謝!
我敢肯定分頁庫只是爲您生成的鏈接,它給你傳遞的偏移量和限制模型的get()函數(或者無論你怎麼稱呼它)。 – jessica
確切地說,看看get_where,它有你所需要的。 – Ben
你能給我一個提示或樣品嗎?即時通訊剛剛進入PHP編程 – nhoyti