help with a mySQLi recordset
Hello there, I have a MySQLi recordset that takes in 2 URL parameters:
?Department=&Category=
And I have a dropdown menu, so for example the Menu item 'Living' would be department and it would contain many categories. So that all works fine...however lets say on my homepage I have a info-graphic link for 'Living' so if the user clicks on that it will take them to the page that will display ALL categories items. How can i do this?
The example URL would be:
category.php?Department=Living&Category=Occasional-Chairs
But lets say I have an infor-graphic link that directs to:
category.php?Department=Living
My recordset is:
<?php
if(true){
switch(isset($_GET['Department'])?$_GET['Department']:""){
case "New-Arrivals":
$rsProducts = new WA_MySQLi_RS("rsProducts",$ecartdb,0);
$rsProducts->setQuery("SELECT * FROM products WHERE ProductNewArrival = 1");
$rsProducts->execute();
break;
case "Best-Sellers":
$rsProducts = new WA_MySQLi_RS("rsProducts",$ecartdb,0);
$rsProducts->setQuery("SELECT * FROM products WHERE ProductBestSeller = 1");
$rsProducts->execute();
break;
case "InStore-Now":
$rsProducts = new WA_MySQLi_RS("rsProducts",$ecartdb,0);
$rsProducts->setQuery("SELECT * FROM products WHERE ProductInStoreNow = 1");
$rsProducts->execute();
break;
case "Search":
$rsProducts = new WA_MySQLi_RS("rsProducts",$ecartdb,0);
$rsProducts->setQuery("SELECT * FROM products");
if (isset($_GET["Price"])) {
$prices = explode(":",$_GET["Price"]);
$rsProducts->addFilter("ProductPrice",">=","d",$prices[0]);
$rsProducts->addFilter("ProductPrice","<=","d",$prices[1]);
}
$productTypes = array();
if (isset($_GET["Wood"])) {
$productTypes[] = "Wood";
}
if (isset($_GET["Metal"])) {
$productTypes[] = "Metal";
}
if (isset($_GET["Glass"])) {
$productTypes[] = "Glass";
}
if (sizeof($productTypes) > 0) $rsProducts->addFilter("ProductType","=","s",$productTypes);
if (isset($_GET["Product"])) {
$productName = $_GET["Product"];
$splitName = explode(" ",$productName);
for ($x=0; $x<sizeof($splitName); $x++) {
$splitName[$x] = "%" . $splitName[$x]."%";
}
$rsProducts->addFilter("ProductKeywords","LIKE","s",$splitName);
}
$rsProducts->setFilter();
$rsProducts->execute();
break;
default:
$rsProducts = new WA_MySQLi_RS("rsProducts",$ecartdb,0);
$rsProducts->setQuery("SELECT products.*, categories.* FROM products INNER JOIN categories ON products.ProductCategoryID = categories.CategoryID WHERE categories.CategoryLink = ? AND categories.CategoryLocation = ?");
$rsProducts->bindParam("s", "".(isset($_GET['Category'])?$_GET['Category']:"") ."", "-1"); //WAQB_Param1
$rsProducts->bindParam("s", "".(isset($_GET['Department'])?$_GET['Department']:"") ."", "-1"); //WAQB_Param2
$rsProducts->execute();
break;
}
}
?>
Regards
Chris