CodeIgniter 搜索分页有点有关问题,帮忙看下

php中文网
发布: 2016-06-13 13:53:11
原创
1102人浏览过

CodeIgniter 搜索分页有点问题,帮忙看下
我的查询条件比较多,所以可能稍微显得长了点,分页是可以用,但是点击下一页,跳转到第二页的时候,下面的当前页并不是第二页!请指教。

主要问题就是,点击下一页的时候,已经跳转到下一页,但是当前页显示不正确!控制器

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->function people_daozhen($askdate,$askdate2,$name,$age,$age2,$phone,$sex,$zxjb,$comefrom,$area){
                
                                
                if(!empty($_POST['askdate'])){
                        $data ['askdate']=$_POST['askdate'];
                }
        
                if(!empty($_POST['askdate2'])){
                        $data ['askdate2']=$_POST['askdate2'];
                }
                if(!empty($_POST['name'])){
                        $data ['name']=$_POST['name'];
                }
                if(!empty($_POST['age'])){
                        $data ['age']=$_POST['age'];
                }
                if(!empty($_POST['age2'])){
                        $data ['age2']=$_POST['age2'];
                }
                if(!empty($_POST['phone'])){
                        $data ['phone']=$_POST['phone'];
                }
                if(!empty($_POST['sex'])){
                        $data ['sex']=$_POST['sex'];
                }
                if(!empty($_POST['zxjb'])){
                        $data ['zxjb']=$_POST['zxjb'];
                }
                if(!empty($_POST['comefrom'])){
                        $data ['comefrom']=$_POST['comefrom'];
                }
                if(!empty($_POST['area'])){
                        $data ['area']=$_POST['area'];
                }
                
                
                $this->load->helper ( 'url' );
                $this->load->database();   
                $this->load->library ( 'pagination' );
                
                
                $config ['per_page'] = '10';
                $config ['base_url'] = base_url(). 'index.php/people/people_daozhen/'.$askdate.'/'.$askdate2.'/'.$name.'/'.$age.'/'.$age2.'/'.$phone.'/'.$sex.'/'.$zxjb.'/'.$comefrom.'/'.$area;
                
                $this->load->model ( 'people_mdl','',TRUE );
 
                $data ['datalist']  = $this->people_mdl->people_list2 ( $config ['per_page'], $this->uri->segment ( 13 ) ,$askdate,$askdate2,$name,$age,$age2,$phone,$sex,$zxjb,$comefrom,$area);
                $config ['total_rows'] =$this->people_mdl->people_sum2($askdate,$askdate2,$name,$age,$age2,$phone,$sex,$zxjb,$comefrom,$area);
                
                $config['uri_segment'] = 3;
                $config ['full_tag_open'] = '<p>';
                $config ['full_tag_close'] = '</p>';
                $config ['first_link'] = '首页';
                $config ['first_tag_open'] = '<li>'; 
                $config ['first_tag_close'] = '</li>';
                $config ['last_link'] = '尾页'; 
                $config ['last_tag_open'] = '<li>';
                $config ['last_tag_close'] = '</li>';
                $config ['next_link'] = '下一页';
                $config ['next_tag_open'] = '<li>';
                $config ['next_tag_close'] = '</li>';
                $config ['prev_link'] = '上一页';
                $config ['prev_tag_open'] = '<li>';
                $config ['prev_tag_close'] = '</li>';
                $config ['cur_tag_open'] = '<li class="current">';
                $config ['cur_tag_close'] = '</li>';
                $config ['num_tag_open'] = '<li>';
                $config ['num_tag_close'] = '</li>';
                $this->pagination->initialize ( $config );
                
 
                
                $this->load->view ( 'admin/people_daozhen', $data );
        }

登录后复制

模型

 
PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->        function people_list2($per_nums, $start_position,$askdate,$askdate2,$name,$age,$age2,$phone,$sex,$zxjb,$comefrom,$area){
                if($askdate!=0){
                        $this-&gt;db-&gt;where('askdate &gt;=',$askdate);
                }
                if($askdate2!=0){
                        $this-&gt;db-&gt;where('askdate db-&gt;like('username',$name);
                }
                if($age!=0){
                        $this-&gt;db-&gt;where('age &gt;=',$age);
                }
                if($age2!=0){
                        $this-&gt;db-&gt;where('age db-&gt;like('phone',$phone);
                }
                if($sex!=0){
                        $this-&gt;db-&gt;where('sex',$sex);
                }
                if($zxjb!=0){
                        $this-&gt;db-&gt;where('zxjb',$zxjb);
                }
                if($comefrom!=0){
                        $this-&gt;db-&gt;where('comefrom',$comefrom);
                }
                if($area!=0){
                        $this-&gt;db-&gt;where('area',$area);
                }
                
                if($askdate!=0){
                        $this-&gt;db-&gt;where('askdate &gt;=',$askdate);
                }
                
                $this-&gt;db-&gt;order_by("pid", "desc"); 
                $query = $this-&gt;db-&gt;get ($_SESSION['user']-&gt;table, $per_nums, $start_position );
                $datas['array']=$query-&gt;result_array();
                $datas['rows']=$query-&gt;num_rows();
                return $query-&gt;result_array();
        }
        
        function people_sum2($askdate,$askdate2,$name,$age,$age2,$phone,$sex,$zxjb,$comefrom,$area){
                if($askdate!=0){
                        $this-&gt;db-&gt;where('askdate &gt;=',$askdate);
                }
                if($askdate2!=0){
                        $this-&gt;db-&gt;where('askdate db-&gt;like('username',$name);
                }
                if($age!=0){
                        $this-&gt;db-&gt;where('age &gt;=',$age);
                }
                if($age2!=0){
                        $this-&gt;db-&gt;where('age db-&gt;like('phone',$phone);
                }
                if($sex!=0){
                        $this-&gt;db-&gt;where('sex',$sex);
                }
                if($zxjb!=0){
                        $this-&gt;db-&gt;where('zxjb',$zxjb);
                }
                if($comefrom!=0){
                        $this-&gt;db-&gt;where('comefrom',$comefrom);
                }
                if($area!=0){
                        $this-&gt;db-&gt;where('area',$area);
                }
                
                $query = $this-&gt;db-&gt;get ($_SESSION['user']-&gt;table);
                return $query-&gt;num_rows();
        }
 <div class="clear"></div>
登录后复制
最佳 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号