首页 > php教程 > PHP源码 > 正文

codeigniter get分页教程

PHP中文网
发布: 2016-05-25 17:05:40
原创
1283人浏览过

php代码

CRMEB开源商城系统(PHP)免费商用
CRMEB开源商城系统(PHP)免费商用

CRMEB开源商城系统可免费商用,框架采用ThinkPHP6+MySQL+elementUI+uniapp,商城系统代码全部开源;前后台都支持风格切换,包含小程序商城、H5商城、公众号商城、App,支持多语言、分销、拼团、砍价、秒杀、优惠券、积分、抽奖、会员等级、小程序直播、页面DIY,前后端分离,方便二开,使用文档、接口文档、数据字典、代码生成、二开文档/视频教程。

CRMEB开源商城系统(PHP)免费商用 1597
查看详情 CRMEB开源商城系统(PHP)免费商用
 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 < ',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);
    }
登录后复制
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
最新问题
热门推荐
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号