fastsol1
07-25-2010, 02:23 AM
So I am making a products area and I have a left sidebar that will hold the categories and the brands with in the categories. What I want is the list to only show the main categories until a category is selected then once the page f=refreshes with the GET variable the list will change to show the brands with in the category selected. Now I can get is to show all the brands in the categories but not just the one that is selected. I think I am on the right track with this but just can't seem to get it. Here is a link to the page so you can see the result - http://shootersbilliardclub.com/store.php I am echoing the id's so you can see the numbers as to where they should be in relation to the category numbers and how they are not showing that way.
$_GET['catid'] = mysql_real_escape_string($_GET['catid']);
$catid = $_GET['catid'];
$get_brands = mysql_query("SELECT * FROM prod_brands");
$brands = mysql_fetch_array($get_brands);
$brand_id = $brands['brand_id'];
$brand = $brands['brand'];
$b_cat_id = $brands['b_cat_id'];
$get_cats = mysql_query("SELECT * FROM prod_cats");
echo "<ul class='categories'>";
while ($cats = mysql_fetch_array($get_cats))
{
$prod_cat_id = $cats['prod_cat_id'];
$prod_cat_title = $cats['prod_cat_title'];
echo $prod_cat_id;
echo "<a href='store.php?catid=$prod_cat_id'><li>$prod_cat_title</li></a>";
if ($catid)
{
if ($b_cat_id == $_GET['catid'])
{
if ($b_cat_id !==0)
{
while ($brands = mysql_fetch_array($get_brands))
{
$brand_id = $brands['brand_id'];
$brand = $brands['brand'];
$b_cat_id = $brands['b_cat_id'];
echo $b_cat_id;
echo "<ul><li><a href='b-products.php?b_id=$brand_id'>$brand</a></li></ul>";
}
}
else {}
}
}
else{}
}
echo "</ul>";
$_GET['catid'] = mysql_real_escape_string($_GET['catid']);
$catid = $_GET['catid'];
$get_brands = mysql_query("SELECT * FROM prod_brands");
$brands = mysql_fetch_array($get_brands);
$brand_id = $brands['brand_id'];
$brand = $brands['brand'];
$b_cat_id = $brands['b_cat_id'];
$get_cats = mysql_query("SELECT * FROM prod_cats");
echo "<ul class='categories'>";
while ($cats = mysql_fetch_array($get_cats))
{
$prod_cat_id = $cats['prod_cat_id'];
$prod_cat_title = $cats['prod_cat_title'];
echo $prod_cat_id;
echo "<a href='store.php?catid=$prod_cat_id'><li>$prod_cat_title</li></a>";
if ($catid)
{
if ($b_cat_id == $_GET['catid'])
{
if ($b_cat_id !==0)
{
while ($brands = mysql_fetch_array($get_brands))
{
$brand_id = $brands['brand_id'];
$brand = $brands['brand'];
$b_cat_id = $brands['b_cat_id'];
echo $b_cat_id;
echo "<ul><li><a href='b-products.php?b_id=$brand_id'>$brand</a></li></ul>";
}
}
else {}
}
}
else{}
}
echo "</ul>";