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'] = '
模型
- 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>

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

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.

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.

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.

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.

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

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.

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.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

Dreamweaver CS6
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!
