国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

codeigniter實現get分頁的方法

2024-04-25 20:38:48
字體:
來源:轉載
供稿:網友

本文實例講述了codeigniter實現get分頁的方法。分享給大家供大家參考。具體實現方法如下:

public function project_search(){

$this->load->library('pagination');

$this->load->model('depart_mdl');

//獲取搜索需要的信息

$data = $this->get_project_data();

$get_data = $this->input->get();

$data = array_merge($data,$get_data);

//get分頁配置

$name = $get_data['name'];

$username = $get_data['username'];

$budget = $get_data['budget'];

$type = $get_data['type'];

$posttime_start = $get_data['posttime_start'];

$posttime_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&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;

//偏移量

$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('depart_code',$get_data['depart_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']);

}

//時間

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();

//處理

for($i=0;$i<count($projects);$i++){

$projects[$i]['type'] = $this->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]['depart'] = $this->depart_mdl->get_depart_by_code($projects[$i]['depart_code'])->name;

}

$data['projects'] = $projects;

//獲取當前用戶的角色

$data['user_role'] = $this->user_mdl->get_user_by_salary_no($this->session->userdata('salary_no'))->role;

$this->_template('project_search',$data);

}

希望本文所述對大家基于codeigniter的php程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 金华市| 彩票| 荣成市| 开江县| 休宁县| 平塘县| 永修县| 同德县| 信阳市| 庆城县| 东方市| 彭水| 浦东新区| 高清| 西乌| 祁连县| 延长县| 中江县| 内乡县| 大兴区| 庆城县| 光山县| 遵义县| 启东市| 湖北省| 二手房| 社会| 周口市| 保山市| 叶城县| 武清区| 容城县| 延庆县| 澄江县| 镇平县| 怀来县| 新蔡县| 石柱| 集安市| 清镇市| 大悟县|