我的查询条件比较多,所以可能稍微显得长了点,分页是可以用,但是点击下一页,跳转到第二页的时候,下面的当前页并不是第二页!请指教。
主要问题就是,点击下一页的时候,已经跳转到下一页,但是当前页显示不正确!控制器
php codefunction people_daozhen($askdate,$askdate2,$name,$age,$age2,$phone,$sex,$zxjb,$comefrom,$area){ if(!empty($_post['askdate'])){ $data ['askdate']=$_post['askdate']; } if(!empty($_post['askdate2'])){ $data ['askdate2']=$_post['askdate2']; } if(!empty($_post['name'])){ $data ['name']=$_post['name']; } if(!empty($_post['age'])){ $data ['age']=$_post['age']; } if(!empty($_post['age2'])){ $data ['age2']=$_post['age2']; } if(!empty($_post['phone'])){ $data ['phone']=$_post['phone']; } if(!empty($_post['sex'])){ $data ['sex']=$_post['sex']; } if(!empty($_post['zxjb'])){ $data ['zxjb']=$_post['zxjb']; } if(!empty($_post['comefrom'])){ $data ['comefrom']=$_post['comefrom']; } if(!empty($_post['area'])){ $data ['area']=$_post['area']; } $this->load->helper ( 'url' ); $this->load->database(); $this->load->library ( 'pagination' ); $config ['per_page'] = '10'; $config ['base_url'] = base_url(). 'index.php/people/people_daozhen/'.$askdate.'/'.$askdate2.'/'.$name.'/'.$age.'/'.$age2.'/'.$phone.'/'.$sex.'/'.$zxjb.'/'.$comefrom.'/'.$area; $this->load->model ( 'people_mdl','',true ); $data ['datalist'] = $this->people_mdl->people_list2 ( $config ['per_page'], $this->uri->segment ( 13 ) ,$askdate,$askdate2,$name,$age,$age2,$phone,$sex,$zxjb,$comefrom,$area); $config ['total_rows'] =$this->people_mdl->people_sum2($askdate,$askdate2,$name,$age,$age2,$phone,$sex,$zxjb,$comefrom,$area); $config['uri_segment'] = 3; $config ['full_tag_open'] = ''; $config ['full_tag_close'] = '
'; $config ['first_link'] = '首页'; $config ['first_tag_open'] = '
'; $config ['first_tag_close'] = ''; $config ['last_link'] = '尾页'; $config ['last_tag_open'] = ''; $config ['last_tag_close'] = ''; $config ['next_link'] = '下一页'; $config ['next_tag_open'] = ''; $config ['next_tag_close'] = ''; $config ['prev_link'] = '上一页'; $config ['prev_tag_open'] = ''; $config ['prev_tag_close'] = ''; $config ['cur_tag_open'] = ''; $config ['cur_tag_close'] = ''; $config ['num_tag_open'] = ''; $config ['num_tag_close'] = ''; $this->pagination->initialize ( $config ); $this->load->view ( 'admin/people_daozhen', $data ); }
模型
php code function people_list2($per_nums, $start_position,$askdate,$askdate2,$name,$age,$age2,$phone,$sex,$zxjb,$comefrom,$area){ if($askdate!=0){ $this->db->where('askdate >=',$askdate); } if($askdate2!=0){ $this->db->where('askdate db->like('username',$name); } if($age!=0){ $this->db->where('age >=',$age); } if($age2!=0){ $this->db->where('age db->like('phone',$phone); } if($sex!=0){ $this->db->where('sex',$sex); } if($zxjb!=0){ $this->db->where('zxjb',$zxjb); } if($comefrom!=0){ $this->db->where('comefrom',$comefrom); } if($area!=0){ $this->db->where('area',$area); } if($askdate!=0){ $this->db->where('askdate >=',$askdate); } $this->db->order_by(pid, desc); $query = $this->db->get ($_session['user']->table, $per_nums, $start_position ); $datas['array']=$query->result_array(); $datas['rows']=$query->num_rows(); return $query->result_array(); } function people_sum2($askdate,$askdate2,$name,$age,$age2,$phone,$sex,$zxjb,$comefrom,$area){ if($askdate!=0){ $this->db->where('askdate >=',$askdate); } if($askdate2!=0){ $this->db->where('askdate db->like('username',$name); } if($age!=0){ $this->db->where('age >=',$age); } if($age2!=0){ $this->db->where('age db->like('phone',$phone); } if($sex!=0){ $this->db->where('sex',$sex); } if($zxjb!=0){ $this->db->where('zxjb',$zxjb); } if($comefrom!=0){ $this->db->where('comefrom',$comefrom); } if($area!=0){ $this->db->where('area',$area); } $query = $this->db->get ($_session['user']->table); return $query->num_rows(); }
