$sql = "SELECT COUNT( '1' ) AS `num`
FROM `tbl_product`
WHERE `cat_id` =$cat_id
AND `product_status` =1";
下面:
$cat_id = 1
product_status = 1= active
在上面的代码中,我可以将num作为7,因为有7种产品基于cat_id
$sqi = "SELECT COUNT( '1' ) AS `num` *
FROM tbl_cat
JOIN tbl_product ON tbl_cat.cat_id = tbl_product.cat_id
AND product_name LIKE '%$similar%'
AND cat_name LIKE '%$field%'"
下面:
cat_id=1
$similar = input value
$field = cat_id(Value)
但是在上面的查询中,我无法使用搜索按钮将数字设为7 所以任何人都可以帮助我。
谢谢!