include("_include_top.php"); ?> $conn = db(); ########################################### # LIST CATEGORIES (WITH PRODUCTS INSIDE) ########################################### $sql = "SELECT DISTINCT product_cat.* FROM product_cat INNER JOIN product ON product_cat.ID=product.idcategorie WHERE product_cat.affiche=1 AND product.ID>1 ORDER BY product_cat.ordre"; $res = $conn->real_query($sql); $res = $conn->use_result(); if(!empty($res)){ while ($row = $res->fetch_assoc()) { if($row['friendlyurl']==$_REQUEST["cat"]){$buffstrong=" strong";$currentcat=$row['ID'];}else{$buffstrong="";} $buffcat = $buffcat . '
'; } } unset($res); unset($result); ########################################### # LIST MANUFACTURER ########################################### $sql = "SELECT DISTINCT manufacturer FROM product WHERE LENGTH(manufacturer)>2 AND showitem=1 AND ID>1 ORDER BY manufacturer"; $res = $conn->real_query($sql); $res = $conn->use_result(); if(!empty($res)){ while ($row = $res->fetch_assoc()) { if($row['manufacturer']==$_REQUEST["manufacturer"]){$buffstrong=" strong";$currentmanufacturer=$row['manufacturer'];}else{$buffstrong="";} $buffmanufacturer = $buffmanufacturer . ''; } } unset($res); unset($result); ########################################### # LIST PRODUCTS ########################################### $nbproduct=0; if(!empty($currentcat)){#SEARCH CATEGORIES $sql = "SELECT * FROM product WHERE ID>1 AND showitem=1 AND idcategorie=" .$currentcat. " ORDER BY promotion DESC, newproduct DESC,showhomepage DESC, datecreated DESC, ID DESC"; #GET CATEGORY DESCRIPTION $sql2= 'SELECT description FROM product_cat WHERE ID=' .$currentcat; $res2=$conn->query($sql2); $row2 = $res2->fetch_assoc(); $catdescription=$row2["description"]; #UPDATE COUNTER if($_SESSION['product_cat']!=$currentcat){ $sql2= 'UPDATE product_cat SET nbvisits=nbvisits+1 WHERE ID=' .$currentcat; if ($conn->query($sql2) !== TRUE) { aff("ERROR:" .$sql2); echo "Error: " . $conn->error; die(); } } $_SESSION['product_cat']=$currentcat; }elseif(!empty($currentmanufacturer)){#SEARCH MANUFACTURER $sql = "SELECT * FROM product WHERE ID>1 AND showitem=1 AND manufacturer='" .$currentmanufacturer. "' ORDER BY promotion DESC, newproduct DESC,showhomepage DESC, datecreated DESC, ID DESC"; }elseif(!empty($_REQUEST['search'])){#SEARCH KEYWORD #SAVE KEYWORD if($_SESSION['keyword']!=$_REQUEST['search']){ $sql = "SELECT ID FROM searchstats WHERE word='" .$_REQUEST['search']. "'"; $res=$conn->query($sql); $row = $res->fetch_assoc(); $IDsearchstats=$row["ID"]; if(empty($IDsearchstats)){ $sql2 = 'INSERT INTO searchstats(word,nbsearch) VALUES("' .$_REQUEST['search']. '",0)'; }else{ $sql2= 'UPDATE searchstats SET nbsearch=nbsearch+1 WHERE ID=' .$IDsearchstats; } if ($conn->query($sql2) !== TRUE) { aff("ERROR:" .$sql2); echo "Error: " . $conn->error; die(); } unset($res); $_SESSION['keyword']=$_REQUEST['search']; } $sql = "SELECT * FROM product WHERE ID>1 AND showitem=1 AND (titre LIKE '%" .$_REQUEST['search']. "%' OR description LIKE '%" .$_REQUEST['search']. "%' OR manufacturer LIKE '%" .$_REQUEST['search']. "%') ORDER BY promotion DESC,newproduct DESC, showhomepage DESC, datecreated DESC, ID DESC"; $ResultTitle = 'Result for "' .$_REQUEST['search']. '"