• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

codeigniter实现get分页的方法_php技巧

php 搞代码 3年前 (2022-01-26) 51次浏览 已收录 0个评论

本文实例讲述了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_<a>本2文来*源gao($daima.com搞@代@#码(网</a><strong>搞gaodaima代码</strong>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程序设计有所帮助。


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:codeigniter实现get分页的方法_php技巧
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址