{$_GET["search"]}...
";
$pname=mysqli_real_escape_string($con,$_GET["search"]);
$whr=" where PNAME like '%{$pname}%'";
}
#category filter
$data["cate_dropdown"]="All";
if(isset($_GET["cate"])){
if($_GET["cate"]!="All"){
$data["cate_dropdown"]=$_GET["cate"];
$whr="where CNAME='".mysqli_real_escape_string($con,urldecode($_GET["cate"]))."' ";
}
}
#Price filter
$data["price_dropdown"]="Default";
if(isset($_GET["price"])){
if($_GET["price"]!="Default"){
$type=urldecode($_GET["price"]);
if($type=='Price Low to High'){
$data["price_dropdown"]=$_GET["price"];
$whr=" order by PRICE asc";
}
else if($type=='Price High to Low'){
$data["price_dropdown"]=$_GET["price"];
$whr=" order by PRICE desc";
}
}
}
#category filter
if(isset($_GET["tag"])){
$data["title"]="Tag result for {$_GET["tag"]}...
";
$whr="where TAGS like '%".urldecode($_GET["tag"])."%' ";
}
#get Products
$sql="select * from products p inner join cate1 c on p.CID=c.CID {$whr}";
$data["products"]=execute($con,$sql);
#get Images
foreach($data["products"] as $row){
$sql="select * from images where PID='{$row["PID"]}' order by PIID asc limit 1";
$data[$row["PID"]]=single($con,$sql);
}
#get rating
foreach($data["products"] as $row){
$sql="select round(avg(RATING),0) as rating,count(RATING) as nos from comments where PID='{$row["PID"]}'";
$data["rating"][$row["PID"]]=single($con,$sql);
}
?>