search
HomeBackend DevelopmentPHP Tutorial CodeIgniter 搜索分页有点有关问题,帮忙看下

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'] = '
  • '; $config ['first_tag_close'] = '
  • '; $config ['last_link'] = '尾页'; $config ['last_tag_open'] = '
  • '; $config ['last_tag_close'] = '
  • '; $config ['next_link'] = '下一页'; $config ['next_tag_open'] = '
  • '; $config ['next_tag_close'] = '
  • '; $config ['prev_link'] = '上一页'; $config ['prev_tag_open'] = '
  • '; $config ['prev_tag_close'] = '
  • '; $config ['cur_tag_open'] = '
  • '; $config ['cur_tag_close'] = '
  • '; $config ['num_tag_open'] = '
  • '; $config ['num_tag_close'] = '
  • '; $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->db->where('askdate >=',$askdate);
                    }
                    if($askdate2!=0){
                            $this->db->where('askdate db->like('username',$name);
                    }
                    if($age!=0){
                            $this->db->where('age >=',$age);
                    }
                    if($age2!=0){
                            $this->db->where('age db->like('phone',$phone);
                    }
                    if($sex!=0){
                            $this->db->where('sex',$sex);
                    }
                    if($zxjb!=0){
                            $this->db->where('zxjb',$zxjb);
                    }
                    if($comefrom!=0){
                            $this->db->where('comefrom',$comefrom);
                    }
                    if($area!=0){
                            $this->db->where('area',$area);
                    }
                    
                    if($askdate!=0){
                            $this->db->where('askdate >=',$askdate);
                    }
                    
                    $this->db->order_by("pid", "desc"); 
                    $query = $this->db->get ($_SESSION['user']->table, $per_nums, $start_position );
                    $datas['array']=$query->result_array();
                    $datas['rows']=$query->num_rows();
                    return $query->result_array();
            }
            
            function people_sum2($askdate,$askdate2,$name,$age,$age2,$phone,$sex,$zxjb,$comefrom,$area){
                    if($askdate!=0){
                            $this->db->where('askdate >=',$askdate);
                    }
                    if($askdate2!=0){
                            $this->db->where('askdate db->like('username',$name);
                    }
                    if($age!=0){
                            $this->db->where('age >=',$age);
                    }
                    if($age2!=0){
                            $this->db->where('age db->like('phone',$phone);
                    }
                    if($sex!=0){
                            $this->db->where('sex',$sex);
                    }
                    if($zxjb!=0){
                            $this->db->where('zxjb',$zxjb);
                    }
                    if($comefrom!=0){
                            $this->db->where('comefrom',$comefrom);
                    }
                    if($area!=0){
                            $this->db->where('area',$area);
                    }
                    
                    $query = $this->db->get ($_SESSION['user']->table);
                    return $query->num_rows();
            }
     <div class="clear">
                     
                  
                  
            
                </div>
    Statement
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    How do you modify data stored in a PHP session?How do you modify data stored in a PHP session?Apr 27, 2025 am 12:23 AM

    TomodifydatainaPHPsession,startthesessionwithsession_start(),thenuse$_SESSIONtoset,modify,orremovevariables.1)Startthesession.2)Setormodifysessionvariablesusing$_SESSION.3)Removevariableswithunset().4)Clearallvariableswithsession_unset().5)Destroythe

    Give an example of storing an array in a PHP session.Give an example of storing an array in a PHP session.Apr 27, 2025 am 12:20 AM

    Arrays can be stored in PHP sessions. 1. Start the session and use session_start(). 2. Create an array and store it in $_SESSION. 3. Retrieve the array through $_SESSION. 4. Optimize session data to improve performance.

    How does garbage collection work for PHP sessions?How does garbage collection work for PHP sessions?Apr 27, 2025 am 12:19 AM

    PHP session garbage collection is triggered through a probability mechanism to clean up expired session data. 1) Set the trigger probability and session life cycle in the configuration file; 2) You can use cron tasks to optimize high-load applications; 3) You need to balance the garbage collection frequency and performance to avoid data loss.

    How can you trace session activity in PHP?How can you trace session activity in PHP?Apr 27, 2025 am 12:10 AM

    Tracking user session activities in PHP is implemented through session management. 1) Use session_start() to start the session. 2) Store and access data through the $_SESSION array. 3) Call session_destroy() to end the session. Session tracking is used for user behavior analysis, security monitoring, and performance optimization.

    How can you use a database to store PHP session data?How can you use a database to store PHP session data?Apr 27, 2025 am 12:02 AM

    Using databases to store PHP session data can improve performance and scalability. 1) Configure MySQL to store session data: Set up the session processor in php.ini or PHP code. 2) Implement custom session processor: define open, close, read, write and other functions to interact with the database. 3) Optimization and best practices: Use indexing, caching, data compression and distributed storage to improve performance.

    Explain the concept of a PHP session in simple terms.Explain the concept of a PHP session in simple terms.Apr 26, 2025 am 12:09 AM

    PHPsessionstrackuserdataacrossmultiplepagerequestsusingauniqueIDstoredinacookie.Here'showtomanagethemeffectively:1)Startasessionwithsession_start()andstoredatain$_SESSION.2)RegeneratethesessionIDafterloginwithsession_regenerate_id(true)topreventsessi

    How do you loop through all the values stored in a PHP session?How do you loop through all the values stored in a PHP session?Apr 26, 2025 am 12:06 AM

    In PHP, iterating through session data can be achieved through the following steps: 1. Start the session using session_start(). 2. Iterate through foreach loop through all key-value pairs in the $_SESSION array. 3. When processing complex data structures, use is_array() or is_object() functions and use print_r() to output detailed information. 4. When optimizing traversal, paging can be used to avoid processing large amounts of data at one time. This will help you manage and use PHP session data more efficiently in your actual project.

    Explain how to use sessions for user authentication.Explain how to use sessions for user authentication.Apr 26, 2025 am 12:04 AM

    The session realizes user authentication through the server-side state management mechanism. 1) Session creation and generation of unique IDs, 2) IDs are passed through cookies, 3) Server stores and accesses session data through IDs, 4) User authentication and status management are realized, improving application security and user experience.

    See all articles

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Tools

    Atom editor mac version download

    Atom editor mac version download

    The most popular open source editor

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    EditPlus Chinese cracked version

    EditPlus Chinese cracked version

    Small size, syntax highlighting, does not support code prompt function

    Dreamweaver Mac version

    Dreamweaver Mac version

    Visual web development tools

    SublimeText3 English version

    SublimeText3 English version

    Recommended: Win version, supports code prompts!