Thinkphp framework used
$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>";
}
I wrote it like this, but it cannot be a multi-select query with multiple conditions. Please tell me how to write sql. The best tp sql writing method
In fact, I have never done multi-select box filtering, but it should be possible to do this:
Which brand is selected, just pass the ID, separated by ',', and then do processing in the background to get all the IDs,
then use in Grammar
$where['brand_id'] = array('in',array($id1,$id2,));
I don’t know TP grammar, so I can’t write anything to you.
Multiple selections under one condition, in sql, just use
in
, that’s itin
,就可以了where brand IN ('a','b') AND fun IN('1','2')
where brand IN ('a','b') AND fun IN('1', '2')
Multiple conditions, think carefully about what multi-conditions are in MySQL and. Then when you use TP, declare a $where=array();
$where['name']='test_name',
$where['age']='test_age'...etc. Then just find($where) directly
$where['brand_id'] = array('in',array($id1,$id2,)); Or you haven't read the full TP manual