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;
}
那么就可以确保搜索条件,不会别丢失了。
相关文章:
来源:中国B4C电子商务
最近更新
常用插件
- ecshop通用红包编码
                                  
很多时候,为了结合促销,必须扩展一下ecshop的红包功能。ecshop的红包...
 - ecshop分类树中统计商品数
                                  
最近忙于开发其他项目,在不少朋友不断要求和催促的情况下,做出了该小...
 - ecshop购物车功能改进[插件
                                  
ecshop购物车功能改进[插件套餐]主要是我们最近开发工作和开发项目中。...
 - ecshop降价通知登记插件
                                  
ecshop降价通知登记插件,主要是为了方便某些客户,对商品价格要求比...
 - ecshop红包修改成满多少减
                                  
我们在长期使用ecshop的时候,我们可以发现。ecshop的红包是一个非常强...
 



