|
本帖最后由 gaishishengzhu 于 2011-3-12 09:29 编辑
我的查询条件比较多,所以可能稍微显得长了点,分页是可以用,但是点击下一页,跳转到第二页的时候,下面的当前页并不是第二页!请指教。
主要问题就是,点击下一页的时候,已经跳转到下一页,但是当前页显示不正确!
控制器
PHP复制代码 function 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'] = '<p>';
$config ['full_tag_close'] = '</p>';
$config ['first_link'] = '首页';
$config ['first_tag_open'] = '<li>';
$config ['first_tag_close'] = '</li>';
$config ['last_link'] = '尾页';
$config ['last_tag_open'] = '<li>';
$config ['last_tag_close'] = '</li>';
$config ['next_link'] = '下一页';
$config ['next_tag_open'] = '<li>';
$config ['next_tag_close'] = '</li>';
$config ['prev_link'] = '上一页';
$config ['prev_tag_open'] = '<li>';
$config ['prev_tag_close'] = '</li>';
$config ['cur_tag_open'] = '<li class="current">';
$config ['cur_tag_close'] = '</li>';
$config ['num_tag_open'] = '<li>';
$config ['num_tag_close'] = '</li>';
$this->pagination->initialize ( $config );
$this->load->view ( 'admin/people_daozhen', $data );
} 复制代码
模型
PHP复制代码
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 <=',$askdate2);
}
if($name!=0){
$this->db->like('username',$name);
}
if($age!=0){
$this->db->where('age >=',$age);
}
if($age2!=0){
$this->db->where('age <=',$age2);
}
if($phone!=0){
$this->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 <=',$askdate2);
}
if($name!=0){
$this->db->like('username',$name);
}
if($age!=0){
$this->db->where('age >=',$age);
}
if($age2!=0){
$this->db->where('age <=',$age2);
}
if($phone!=0){
$this->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();
} 复制代码
视图
HTML复制代码 <tr>
<td>日期:从 <input type="text" name="askdate" id="askdate" value="<?php echo $askdate; ?>" onclick="calendar()" onfocus="calendar()" size="10"/>
到 <input type="text" name="askdate2" id="askdate2" value="<?php echo $askdate2; ?>"onclick="calendar()" onfocus="calendar()" size="10"/>
</td>
<td>
名字: <input type="text" name="name" id="name" value="<?php echo $name; ?>" size="10"/>
</td>
<td>
年龄:从 <input type="text" name="age" id="age" value="<?php echo $age; ?>" size="2" maxlength="2"/>
到 <input type="text" name="age2" id="age2" value="<?php echo $age2; ?>" size="2" maxlength="2"/>
</td>
<td>
电话: <input type="text" name="phone" id="phone" value="<?php echo $phone; ?>" size="10" maxlength="12"/>
</td>
</tr>
<tr>
<td>
性别: <select name="sex" id="sex">
<option value="">请选择 </option>
<option value="1" <?php echo $sex==1?'selected':'';?>>女 </option>
<option value="2" <?php echo $sex==2?'selected':'';?>>男 </option>
<option value="3" <?php echo $sex==3?'selected':'';?>>未知 </option>
</select>
科室:
<select name="zxjb" id="zxjb">
<option value="">请选择 </option>
<option value="1" <?php echo $zxjb==1?'selected':'';?>>XX科 </option>
<option value="2" <?php echo $zxjb==2?'selected':'';?> >aa科 </option>
<option value="3" <?php echo $zxjb==3?'selected':'';?>>bb科 </option>
<option value="4" <?php echo $zxjb==4?'selected':'';?>>cc科 </option>
<option value="5" <?php echo $zxjb==5?'selected':'';?>>dd科 </option>
<option value="6" <?php echo $zxjb==6?'selected':'';?>>ee科 </option>
<option value="7" <?php echo $zxjb==7?'selected':'';?>>ff科 </option>
</select>
</td>
<td>
来源:
<select name="comefrom" id="comefrom">
<option value="">请选择 </option>
<option value="1" <?php echo $comefrom==1?'selected':'';?>>网络 </option>
<option value="2" <?php echo $comefrom==2?'selected':'';?>>电话 </option>
<option value="3" <?php echo $comefrom==3?'selected':'';?>>广告 </option>
<option value="4" <?php echo $comefrom==4?'selected':'';?>>路过 </option>
<option value="5" <?php echo $comefrom==5?'selected':'';?>>杂志 </option>
<option value="6" <?php echo $comefrom==6?'selected':'';?>>朋友 </option>
</select>
</td>
<td>
所在区域:
<select name="area" id="area">
<option value="">请选择 </option>
<option value="1" <?php echo $area==1?'selected':'';?>>本市 </option>
<option value="2" <?php echo $area==2?'selected':'';?>>本省 </option>
<option value="3" <?php echo $area==3?'selected':'';?>>外省 </option>
</select>
</td>
<td>
<input type="button" value=" 查 询 " onclick="sel();" />
</td>
</tr>
</table>
</form>
</td>
</tr> 复制代码 |
|