codeigniter实现get分页的方法,codeigniterget分页_PHP教程
程序员文章站
2024-02-17 19:11:58
...
codeigniter实现get分页的方法,codeigniterget分页
本文实例讲述了codeigniter实现get分页的方法。分享给大家供大家参考。具体实现方法如下:
public function project_search(){ $this->load->library('pagination'); $this->load->model('depart_mdl'); //获取搜索需要的信息 $data = $this->get_project_data(); $get_data = $this->input->get(); $data = array_merge($data,$get_data); //get分页配置 $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; //偏移量 $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']); } //时间 if($posttime_start != ''){ $this->db->where('posttime > ',strtotime($get_data['posttime_start'])); } if($posttime_end != ''){ $this->db->where('posttime db->order_by('posttime','desc'); $projects = $this->db->limit($config['per_page'],$page_from)->get()->result_array(); //处理 for($i=0;$imanage_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; //获取当前用户的角色 $data['user_role'] = $this->user_mdl->get_user_by_salary_no($this->session->userdata('salary_no'))->role; $this->_template('project_search',$data); }
希望本文所述对大家基于codeigniter的php程序设计有所帮助。
下一篇: mysql排序有关问题
推荐阅读
-
codeigniter实现get分页的方法,codeigniterget分页_PHP教程
-
php数组分页实现方法,php数组分页_PHP教程
-
codeigniter实现get分页的方法
-
详解PHP+AJAX无刷新分页实现方法,ajax分页_PHP教程
-
php简单实现数组分页的方法,php数组分页_PHP教程
-
PHP使用Mysqli类库实现完美分页效果的方法,mysqli类库
-
codeigniter中测试通过的分页类示例_PHP教程
-
ajax完美实现两个网页 分页功能的实例代码_PHP教程
-
php实现的漂亮分页方法_PHP教程
-
ThinkPHP3.2.3实现分页的方法详解,thinkphp3.2.3分页_PHP教程