ecshop中查询条件如何加到分页中

2009-09-07 14:40 来源:www.chinab4c.com 作者:ecshop专家

    ecshop使用的时候,很多时候需要post表单方式提交查询的数据,并且进行分页。那么post如果过去条件控制呢。那么。我们可以考虑用session来处理。这个方式在电子商务系统中也不是不可取的。

   $province1 = isset($_POST['province'])?$_POST['province']:$_SESSION['pw1'];
 $city1= isset($_POST['city'])?$_POST['city']:$_SESSION['cw1'];
 $district1 = isset($_POST['district'])?$_POST['district']:$_SESSION['dw1'];
 
 $where = '';
 
 if ($province1) {
  $_SESSION['pw1'] = $province1;
  $where.=(($where == '')?' where':' and')." province = '$province1'" ;
  
 }
 if ($city1) {
  $_SESSION['cw1'] = $city1;
  $where.=(($where == '')?' where':' and')." city = '$city1'" ;
 }
 if ($district) {
  $_SESSION['dw1'] = $district1;
  $where.=(($where == '')?' where':' and')." district = '$district1'" ;
 }

  在函数中也需要如此去处理。

  function get_wangdian($start, $num){
 global $db;
 global $ecs;
 $province = isset($_POST['province'])?$_POST['province']:$_SESSION['pw'];
 $city= isset($_POST['city'])?$_POST['city']:$_SESSION['cw'];
 $district = isset($_POST['district'])?$_POST['district']:$_SESSION['dw'];
 global $where;
 $where = '';
 
 if ($province) {
  $_SESSION['pw'] = $province;
  $where.=(($where == '')?' where':' and')." province = '$province'" ;
  
 }
 if ($city) {
  $_SESSION['cw'] = $province;
  $where.=(($where == '')?' where':' and')." city = '$city'" ;
 }
 if ($district) {
  $_SESSION['dw'] = $province;
  $where.=(($where == '')?' where':' and')." district = '$district'" ;
 }
 
 
 $re = $db -> getAll("select * from ".$ecs->table('bussine_user')." $where limit $start, $num");
 return $re;
}

那么就可以确保搜索条件,不会别丢失了。

相关文章:

 使用ecshop电子商务系统的100个小问题

 ecshop订单管理分析

 

来源:中国B4C电子商务