php – 如何使用codeigniter显示分页信息
发布时间:2020-12-13 16:20:32 所属栏目:PHP教程 来源:网络整理
导读:我想在我的页面中显示分页信息. ?像这样下表显示了17本书中的0-8本书 正如下面在评论和答案中解释我试图解决我的问题.但我仍然有问题. 无法获取cur_page值.我试过了 ????????????????????$CI = get_instance(); ?????????????????????$curpage = $CI- pagina
我想在我的页面中显示分页信息.
?像这样下表显示了17本书中的0-8本书 正如下面在评论和答案中解释我试图解决我的问题.但我仍然有问题. >无法获取cur_page值.我试过了 请帮我解决这个问题? 在我的视图页面中 <?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(); } 解决方法
的var_dump($这 – >分页);像这样返回somenthing:
object(CI_Pagination) 21 (31) { ["base_url"]=> string(31) "http://localhost/site/users" ["prefix"]=> string(0) "" ["suffix"]=> string(0) "" ["total_rows"]=> int(3) ["per_page"]=> int(20) ["num_links"]=> int(15) ["cur_page"]=> int(0) ["first_link"]=> string(5) "First" ["next_link"]=> bool(false) ["prev_link"]=> bool(false) ["last_link"]=> string(4) "Last" ["uri_segment"]=> int(2) ["full_tag_open"]=> string(25) "" ["full_tag_close"]=> string(4) "" ["first_tag_open"]=> string(31) "" ["first_tag_close"]=> string(13) " " ["last_tag_open"]=> string(36) " " ["last_tag_close"]=> string(7) "" ["first_url"]=> string(31) "http://localhost/site/users" ["cur_tag_open"]=> string(87) " " ["cur_tag_close"]=> string(11) "" ["next_tag_open"]=> string(36) " " ["next_tag_close"]=> string(13) " " ["prev_tag_open"]=> string(36) " " ["prev_tag_close"]=> string(7) "" ["num_tag_open"]=> string(35) " " ["num_tag_close"]=> string(7) "" ["page_query_string"]=> bool(false) ["query_string_segment"]=> string(8) "per_page" ["display_pages"]=> bool(true) ["anchor_class"]=> string(26) "class="button bradiusMax" " } 我应该做: echo "Showing ".( $this->pagination->cur_page * $this->pagination->per_page)." of ". $this->pagination->total_rows." total results"; 如果你想要,你也可以使用不同的格式,因为itachi在评论中给你看. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |