This topic is locked

Sub categories

3/2/2009 3:00:11 AM
Shopping Cart Template general questions
M
mmponline author

I have a need to put sub categories (and sub sub categories) to my cart. I'm sure I can just add it to the inventory list. My question is how to change the menu that displays on the left to show both categories, sub categories and sub sub categories.

global $conn;

global $dal;

$message = "<b>Catalog</b><br>";

//$str = "select Category_id, Category_class from sccategories";

$rs = $dal->sccategories->QueryAll();

while ($data = db_fetch_array($rs))

{

$str2 = "select count(Item) from scinventory where Category_id='".str_replace("'","\'",$data["Category_id"])."'";

$rs2 = CustomQuery($str2);

$data2 = db_fetch_numarray($rs2);

if ($data2[0])

if (@$_REQUEST["a"]=="search" && @$_REQUEST["SearchFor"]==$data["Category_id"])

$message.= "<a href=\"scinventory_list.php?a=search&value=1&SearchFor=".htmlspecialchars(rawurlencode($data["Category_id"]))."&SearchOption=Contains&SearchField=Category_id\"><b>".ucfirst($data["Category_class"])." (".$data2[0].") </b></a><br>";

else

$message.= "<a href=\"scinventory_list.php?a=search&value=1&SearchFor=".htmlspecialchars(rawurlencode($data["Category_id"]))."&SearchOption=Contains&SearchField=Category_id\">".ucfirst($data["Category_class"])." (".$data2[0].") </a><br>";

}

$message.= "<br><a href=\"scinventory_list.php?a=search&value=1&SearchFor=&SearchOption=Contains&SearchField=Category_id\">Show all</a><br>";

echo $message;


Thanks for assistance.

J
Jane 3/4/2009

Hi,
you need to select sub categories (and sub sub categories from inventory table based on the current category):

$str2 = "select count(Item) from scinventory where Category_id='".str_replace("'","\'",$data["Category_id"])."'";

$rs2 = CustomQuery($str2);

$data2 = db_fetch_numarray($rs2);
$str3 = "select count(Item) from scinventory where Category_id='".str_replace("'","\'",$data2[0])."' and sub_category_id='".str_replace("'","\'",$data["sub_category_id"])."'";

$rs3 = CustomQuery($str3);

$data3 = db_fetch_numarray($rs3);

...