Ok, You guys are my only hope.
Ive been out of coding for a lil over a year and a half, so, my coding is usually outdated, or not very good...
What Im wanting is for the main category to give the total of items, but also ad the total of items in each of its subcategories... thats it, I know its something simple, and I had posted this at codewalkers.com and it upset me because no matter what, it used to be they would at least try to help, but now, its been about 2 weeks on their site, and not one reply... so,, I came to a site that I thought was another one of the best for knowledge... Ive been php coding for 4 years, but had to get a real job for a while... lol.. Thanks
This is what I have:
<?
$query_main_cat = "SELECT * FROM class_categories WHERE sub='0' ORDER BY cat";
$result_main_cat = mysql_query($query_main_cat);
$numrows_main_cat = mysql_num_rows($result_main_cat);
while($main_cat = mysql_fetch_array($result_main_cat)){
$main_cat_id = $main_cat['id'];
$main_cat_sub = $main_cat['sub'];
$main_cat_cat = $main_cat['cat'];
$query_sub_cat = "SELECT * FROM class_categories WHERE sub='$main_cat_id' ORDER BY cat";
$result_sub_cat = mysql_query($query_sub_cat);
$numrows_sub_cat = mysql_num_rows($result_sub_cat);
$query_main_items = "SELECT * FROM class_item WHERE cat_id='$main_cat_id'";
$result_main_items = mysql_query($query_main_items) or die ("Query_Items failed");
$numofrows_main_items = mysql_num_rows($result_main_items);
while($sub_cat = mysql_fetch_array($result_sub_cat)) {
$sub_cat_id = $sub_cat['id'];
$sub_cat_sub = $sub_cat['sub'];
$sub_cat_cat = $sub_cat['cat'];
$query_sub_items = "SELECT * FROM class_item WHERE cat_id='$sub_cat_id'";
$result_sub_items = mysql_query($query_sub_items) or die ("Query_Items failed");
$numofrows_sub_items = mysql_num_rows($result_sub_items);
}
$n = $numofrows_sub_items+$numofrows_main_items;
echo '<font size="2">( '.$n.' ) ';
echo '<font size="2"><b> <a href="http://'.$domain.'/c/';
echo 'results.php?id='.$main_cat_id.'&sub='.$main_cat_sub.'">'.$main_cat_cat.'</a></b><BR>';
}
?>