loop help request

Hi, guys, I am trying to make a small project, but I am stuck over a menu. The thing is that I want to make dynamic menu with categories and I want when I click on a category, the code to polulate subcategories below it, but only from selected catid… I tryed everything I know, but it was not enough - it spins out all subcats. I will appreciate some help…the code so far is the following:
[php]while($cats_list = mysql_fetch_assoc($get_cats_result))
{
$cat_replace = str_replace(" “,”-",$cats_list[‘name’]);
$cat_replace = str_replace("–","-",$cat_replace);
echo “<a href='categor-”.$cat_replace."/".$cats_list[‘idtt’]."’> “.$cats_list[‘accname’].”
“;
$id_cat=(int)$_GET[‘category’];
$sub= “SELECT idtt, catidnum, accname FROM subbasecat WHERE catid=”.$id_cat.” ORDER BY name ASC";
$get_sub_result = mysql_query($sub);
while($sub_list = mysql_fetch_assoc($get_sub_result))
{

				$cat_replace = str_replace(" ","-",$cat_za_profile['accname']);
				$cat_replace = str_replace("--","-",$cat_replace);
				$subcat_replace = str_replace(" ","-",$sub_list['accname']);
				$subcat_replace = str_replace("--","-",$subcat_replace);					
			echo "cat-".$cat_replace."/".$sub_list['catidnum']."/subcat-".$subcat_replace."/".$sub_list['idtt']."'>>><img src='img/list_icon.png' width='15' height='15'/> ".$sub_list['accname']."</a><br /> ";		
			
			
				}
				}[/php]

How does your subcartegory know its grouped in the main category ?
You do not give enough information you expect us to know your fields and what they do.

Do you have catid in the subcategory and they have different ids set to them that corespond to the correct category ?

Hi, thanks for replying. There are different tables. I have category table, where there is id, account id and name. The table with subcats has account id, and category id. that is the connection between data, if I get your question right…

what does account id do ?
How does that hold information about the main category ?

What I am asking is how does the sabcategory know its in the category say toys ?

main category toys = id1 account_id = ??
subcategory cars = id1 account_id = ??
subcategory teddy bears = id2 account_id = ??

main category
car parts = catid1 account_id = ??
toys = catid1 account_id = ??

subcategory
cars = subid1 catid = 1 account_id = ??
teddy bears = subid2 catid = 1 account_id = ??
engine_parts = subid3 catid = 2 account_id = ??

Sponsor our Newsletter | Privacy Policy | Terms of Service