php 商城产品三级联动_用php如何实现这个三级联动

给你个例子参考

数据库:

表1 phase  学段表

字段

phaseId

phaseName 名字

表2 grade  年级表

字段

phaseId

gradeId

gradeName

表3 subject 学科

字段

gradeId

subjectId

subjectName

--------------------------分割线---------------------------------

/**

* 获取页面查询参数数组

*/

private function getParams(){

$params = array();

$params['pagesize'] = 50;

$params['page'] = !empty($_REQUEST['p']) ? $_REQUEST['p'] : 1;

$params['phase'] = $_REQUEST['phase'];

$params['subject'] = $_REQUEST['subject'];

$params['grade'] = $_REQUEST['grade'];

$params['publisher'] = $_REQUEST['publisher'];

$params['city'] = $_REQUEST['city'];

$params['order'] = empty($_REQUEST['order']) ? '' : $_REQUEST['order'];

$params['excellentState'] = isset($_REQUEST['excellentState']) ? $_REQUEST['excellentState'] : '';

$params['judgeState'] = isset($_REQUEST['judgeState']) ? $_REQUEST['judgeState'] : '';

$params['isDel'] = isset($_REQUEST['isDel']) ? $_REQUEST['isDel'] : '';

$params['report'] = isset($_REQUEST['report']) ? $_REQUEST['report'] : '';

$params['keyword'] = isset($_REQUEST['keyword']) ? $_REQUEST['keyword'] : '';

$pattern = '/\+|-|&|\||!|\(|\)|\{|\}|\[|\]|\^|"|~|\*|\?|:|\\\\/';

$params['keyword'] = preg_replace($pattern, '', $params['keyword']);

return $params;

}

/**

* 将查询参数数组转化为查询条件数组

* @param array $params Url查询参数数组

*/

private function getConditions($params){

$limit = $params['pagesize'];

$skip = ($params['page']-1) * $limit;

$conditions = array("limit"=>$limit,"skip"=>$skip);

if(!empty($params['phase'])){

$conditions['phase'] = array('eq',$params['phase']);

}

if(!empty($params['subject'])){

$conditions['subject'] = array('eq',$params['subject']);

}

if(!empty($params['grade'])){

$conditions['grade'] = array('eq',$params['grade']);

}

if(!empty($params['publisher'])){

$conditions['book_name'] = array('like','%'.urldecode($_REQUEST['publisherName']).'%');

}

if($params['keyword'] !='' ){

$where['id'] = array('like', '%' . $params['keyword'] . '%');

$where['name'] = array('like','%' . $params['keyword'] . '%');

$where['user_name'] = array('like','%' . $params['keyword'] . '%');

$where['_logic'] = 'or';

$conditions['_complex'] = $where;

}

if($params['judgeState'] != ''){

$conditions['judge_state'] = array('eq',$params['judgeState']);

}

if($params['excellentState'] != ''){

$conditions['excellent_state'] = array('eq',$params['excellentState']);

}

if(!empty($params['order'])){

$conditions['order'] = $params['order'];

}

if($params['isDel'] == ''){

$conditions['is_del'] = array('neq',1);

}else{

$conditions['is_del'] = array('eq',$params['isDel']);

}

if($params['report'] != ''){

if($params['report'] == 0){

$conditions['id'] = array('exp', ' NOT IN (select package_id from ts_match_report where content_type=1) ');

}else{

$conditions['id'] = array('exp',' IN (select package_id from ts_match_report where content_type=1) ');

}

}

$conditions['package_state'] = array('eq',1);

//省级或全国超管可以查看所有

if ($this->adminType == 'country' || $this->adminType == 'province') {

if(!empty($params['city'])){

$conditions['city_id'] = array('eq',$params['city']);

}

} else if($this->adminType == 'city') {

$params['city'] = $this->adminAreaId;

$conditions['city_id'] = array('eq',$params['city']);

}

return $conditions;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值