CI framework GET paging tutorial

Source: Internet
Author: User
By default, CI paging is submitted in POST mode. In fact, the GET paging tutorial is also very simple, as follows: Apply/config. modify in php: $ config ['uri _ protocol'] = & quot; P

By default, CI paging is submitted in POST mode. In fact, the GET paging tutorial is also very simple, as follows:

Modify application/config. php: $ config ['uri _ protocol'] = "PATH_INFO ";

Yes. now, I can paste a search method in the project:


Public function project_search () {$ this-> load-> library ('pagination'); $ this-> load-> model ('Depart _ mdl '); // obtain the information required for the search $ data = $ this-> get_project_data (); $ get_data = $ this-> input-> get (); $ data = array_merge ($ data, $ get_data); // get page configuration $ name = $ get_data ['name']; $ username = $ get_data ['username']; $ budget = $ get_data ['budget ']; $ type = $ get_data ['type']; $ posttime_start = $ get_data ['posttime _ start']; $ p Osttime_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 & amp & 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; // offset $ 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 ('part _ code', $ get_data ['part _ 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']);} // Time 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 (); // process for ($ I = 0; $ I
 
  
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] ['demo'] = $ this-> depart_mdl-> get_depart_by_code ($ projects [$ I] ['demopart _ Code']) -> name;} $ data ['project'] = $ projects; // Obtain the role $ data ['User _ role'] = $ this-> user_mdl-> get_user_by_salary_no ($ this-> session-> userdata ('salary _ no' )) -> role; $ this-> _ template ('Project _ search', $ data );}
 

You just need to look at the page base_url to understand it! I have not encountered many online tutorials that require URI extension or garbled code. I usually use a new version of CI.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.