php - 电商网站中的多条件筛选需求

查看:231
本文介绍了php - 电商网站中的多条件筛选需求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

用的thinkphp框架

$search=urldecode(I("search"));
        $this->assign('search',$search);
        if(!empty($_POST)){
        
            //$condition = array();
            $condition['goods_name']=array("like","%$search%");
            //I('brand') ? $condition['brand_id'] = I('brand') : false;
            if(I('brand')){
                $condition['brand_id']=
            }
            //$condition['brand_id'] =80;
            //I('func') ? $condition['func'] = I('func') : false;
            //I('price') ? $condition['shop_price'] = I('price') : false;

            var_dump($condition);

            //$gList = M('Goods')->where($condition)->select();
           
            //echo "<pre>";
            //var_dump($gList);
            //echo "</pre>";
            
            
        }

我这样写的但是 并不能多条件多 多选查询 求大神 讲讲sql怎么写 最好tp的sql写法

解决方案

多选框筛选其实我也没做过,但应该可以这样做:
选了哪些品牌,就传ID过去,用‘,’分隔,然后后台做处理,把所有ID搞出来,
再用in语法$where['brand_id'] = array('in',array($id1,$id2,));

这篇关于php - 电商网站中的多条件筛选需求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆