我想在我的页面中显示分页信息。像这样 下表显示了 17 本书中的 0-8 本书
正如下面评论和回答中所解释的,我试图解决我的问题。但我仍然有问题。
无法获取
cur_page
值。我试过$CI =& get_instance(); $curpage=$CI->pagination->cur_page;
但这给了我一个
零值。如果我为
cur_page
. 说 $cur_page=3,我的总记录是 17。然后在最后一页(即 3)显示错误信息showing 24-17 of 17 books
请帮我解决这个问题?
在我的视图页面中
<?php echo "displaying $result_start to $result_end of $total";?>
在控制器中
$config = array();
$config['base_url'] = base_url().'viewallbooks/books/pgn/';
$config["total_rows"] = $this->Booksmodel->record_count_for_secondtopBooks('3');
$config['uri_segment'] = 4;
$config['per_page'] = 8;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
$page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0;
$data["query"] = $this->Subjectmodel->get_subjects();
$data["query1"]= $this->Editionmodel->get_edition();
/*
* For showing the "showing 8-16 of 23 data
*/
$data["flimit"]=$config["per_page"];
$data["slimit"]=$page;
$data["trows"]= $config["total_rows"] ;
/*
* Ends here--For showing the "showing 8-16 of 23 data
*/
$data["query2"]=$this->Booksmodel->get_all_book_list_atHomeTop('3',$config["per_page"], $page);
$data["links"] = $this->pagination->create_links();
$this->load->view('commonfiles/booksview',$data);
在用于计算总行数的模型中
//-- -Counting the rows of bookdetails of table where display_id is as argument-----
public function record_count_for_secondtopBooks($id) {
$this->load->database();
$this->db->where('display_id', $id);
$this->db->from('bookdetails');
return $this->db->count_all_results();
}