DDR爱好者之家 Design By 杰米
本文实例讲述了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 = ""; $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 < ',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(); //处理 for($i=0;$i<count($projects);$i++){ $projects[$i]['type'] = $this->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; //获取当前用户的角色 $data['user_role'] = $this->user_mdl->get_user_by_salary_no($this->session->userdata('salary_no'))->role; $this->_template('project_search',$data); }
希望本文所述对大家基于codeigniter的php程序设计有所帮助。
DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米
暂无评论...
更新日志
2024年11月27日
2024年11月27日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]