这篇文章主要介绍了codeigniter实现get分页的方法,涉及使用codeigniter框架查询数据量及针对结果集进行get方法分页的相关技巧,非常简单实用,需要的朋友可以参考
本文实例讲述了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 db->order_by('posttime','desc');
$projects = $this->db->limit($config['per_page'],$page_from)->get()->result_array();
//处理
for($i=0;$i
希望本文所述对大家基于codeigniter的php程序设计有所帮助。
,
热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境

Atom编辑器mac版下载
最流行的的开源编辑器

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)