This article describes how to implement get paging by codeigniter. it involves the skills of using the codeigniter framework to query data volumes and performing get method paging by result set. it is very simple and practical, for more information about how to implement get paging, see the example in this article. Share it with you for your reference. The specific implementation method is as follows:
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 );}
I hope this article will help you with codeigniter-based php programming.