2 cxz900412 cxz900412 于 2014.08.28 11:26 提问

CI框架中分页关于参数丢失的问题

点击下一页的时候原本的查询结果中的参数的限制都没有了,点击下一个又变成查询所有的了 请问怎么解决呢?
代码如下:
public function message_search(){
$conditions= "message_record.id > 0";
//任务状态查询
if(!empty($_REQUEST['message_type'])){
$message=$_REQUEST['message_type'];
$conditions.= " AND message_record.message_type = '$message' ";
$lang['message_tag'] = $message;
}
//车牌号
if(!empty($_REQUEST['dispath_number'])){
$dispath_number=$_REQUEST['dispath_number'];
$conditions.= " AND message_record.track_plate = '$dispath_number' ";
$lang['dispath_number_tag'] = $dispath_number;
}
//时间搜索
if(!empty($_REQUEST['start_time'])){
$start_time = trim($_REQUEST['start_time']);
$new_time = strtotime($start_time)*1000;
$conditions.=" AND message_record.create_time >= '$new_time' ";
$lang['start_time_tag'] = $start_time;
}
if(!empty($_REQUEST['end_time'])){
$end_time = trim($_REQUEST['end_time']);
$new_time_end = strtotime($end_time)*1000;
$conditions.=" AND message_record.create_time <= '$new_time_end' ";
$lang['end_time_tag'] = $end_time;
}
//计算总的个数
$allDispath = $this->car_dispatch->selectPageDispathSend('message_record','message_record.create_time',$conditions);
//分页设计
$pre_page = 10;//定义每页显示的个数
//$config['base_url'] = site_url('car_job/message_search');
$config['base_url'] = base_url().'car_job/message_search';
$config['total_rows'] = count($allDispath->result()); //总的个数
$config['per_page'] = $pre_page;//每页显示个数
$config['num_links'] = 3;// 当前连接前后显示页码个数
$config['full_tag_open'] = '

'; // 分页开始样式
$config['full_tag_close'] = '
'; // 分页结束样式
$config['first_link'] = '首页'; // 第一页显示
$config['last_link'] = '末页'; // 最后一页显示
$config['next_link'] = '下一页 >'; // 下一页显示
$config['prev_link'] = '< 上一页'; // 上一页显示
$config['cur_tag_open'] = ' '; // 当前页开始样式
$config['cur_tag_close'] = '
'; // 当前页结束样式
$this->pagination->initialize($config);
$lang['create_link'] = $this->pagination->create_links();
$offset =intval($this->uri->segment(3));
$lang['messages'] = $this->car_dispatch->selectPageDispathSend('message_record','message_record.create_time',$conditions,$pre_page,$offset);
$result = $lang['messages']->result();
$message_type = $this->config->item('message');
$carlist = $this->fleet_model->dGetAllCarNum();
$lang['message_type']=$message_type;
$lang['carlist'] = $carlist;
//总页数
$lang['allpagenum'] = totalPage($config['total_rows'], $config['per_page']);
//总条数
$lang['allresult'] = $config['total_rows'];
$this->index();
$this->load->view('car_job/message_search',$lang);

}
Csdn user default icon
上传中...
上传图片
插入图片