CodeIgniter implement get Paging method, Codeigniterget pagination
The example in this article describes how CodeIgniter implements get paging. Share to everyone for your reference. The implementation method is as follows:
Public Function Project_search () {$this->load->library (' pagination '); $this->load->model (' depart_mdl '); Get the information you need to search $data = $this->get_project_data (); $get _data = $this->input->get (); $data = Array_merge ($data, $get _data); Get paging configuration $name = $get _data[' name ']; $username = $get _data[' username '); $budget = $get _data[' Budget '); $type = $get _data[' type ']; $posttime _start = $get _data[' Posttime_start '); $posttime _end = $get _data[' posttime_end '); $purchase _type = $get _data[' Purchase_type '); $depart _code = $get _data[' Depart_code '); $project _status = $get _data[' project_status '); $bidder _way = $get _data[' Bidder_way '); $suffix = "? name= $name &username= $username &budget= $budget &type= $type &posttime_start= $posttime _ start&posttime_end= $posttime _end&purchase_type= $purchase _type&depart_code= $depart _code&project _status= $project _status&bidder_way= $bidder _way "; $config [' base_url '] = Site_url (' Project/project_search '). $suffix; $config[' total_rows '] = $this->db->count_all ($this->db->dbprefix (' project ')); $config [' per_page '] = 10; $config [' page_query_string '] = TRUE; Offset $config [' query_string_segment '] = ' page '; $config [' uri_segment '] = 3; $this->pagination->initialize ($config); $user = $this->user_mdl->get_user_by_salary_no ($this->session->userdata (' salary_no ')); $this->db->from (' Ustc_project '); $this->db->join (' ustc_admins ', ' ustc_admins.salary_no=ustc_project.salary_no '); if ($user->role!=1) {$depart _code = explode (', ', $user->grant_depart_code); $this->db->where_in (' Grant_depart_code ', $depart _code); $this->db->or_where (' Ustc_project.salary_no = ', $this->session->userdata (' salary_no ')); } if ($name! = ") {$this->db->like (' name ', $name); if ($username! = ") {$this->db->like (' username ', $get _data[' username ']); if ($budget! = ") {$this->db->like (' Budget ', $get _data[' budget ']); } if ($type! = ") {$This->db->where (' type ', $get _data[' type '); if ($depart _code! = ") {$this->db->where (' Depart_code ', $get _data[' Depart_code ']); if ($purchase _type! = ") {$this->db->where (' Purchase_type ', $get _data[' Purchase_type ']); if ($project _status! = ") {$this->db->where (' Project_status ', $get _data[' project_status ']); if ($bidder _way! = ") {$this->db->where (' Bidder_way ', $get _data[' Bidder_way ']); }//Time if ($posttime _start! = ") {$this->db->where (' Posttime > ', strtotime ($get _data[' Posttime_start ')); if ($posttime _end! = ") {$this->db->where (' Posttime < ', strtotime ($get _data[' posttime_end ')); } if (Isset ($get _data[' page ')) {$page _from = $get _data[' page ']; }else{$page _from = 0; } $this->db->order_by (' posttime ', ' desc '); $projects = $this->db->limit ($config [' per_page '], $page _from)->get ()->result_array (); Handling for ($i =0; $i
manage_info_mdl->get_value_by_id ($projects [$i] [' type '])->value; $projects [$i] [' purchase_type '] = $this->manage_info_mdl->get_value_by_id ($projects [$i] [' Purchase_type '])- >value; $projects [$i] [' depart '] = $this->depart_mdl->get_depart_by_code ($projects [$i] [' Depart_code '])->name; } $data [' projects '] = $projects; Gets the role of the current user $data [' user_role '] = $this->user_mdl->get_user_by_salary_no ($this->session->userdata (' Salary_no '))->role;
$this->_template (' Project_search ', $data);}
I hope this article is helpful to everyone based on CodeIgniter PHP program design.
http://www.bkjia.com/PHPjc/1030145.html www.bkjia.com true http://www.bkjia.com/PHPjc/1030145.html techarticle CodeIgniter Implement Get pagination method, Codeigniterget pagination This article describes CodeIgniter implementation of get pagination method. Share to everyone for your reference. The concrete implementation method is as follows: P ...