While loop question

Hello,

I am trying to create a list of categories, sub-categories and then a list of “subjects” for those categories. I am using the while loop to create the category/sub-category list. Code Below:

[php]<?php

	//Create Main Category Menu
$subject_set_query= "SELECT * FROM subjects";
$subject_set= mysql_query($subject_set_query, $connect);
{
if(!$subject_set) {
        die("Database Query Failed: " . mysql_error());
	}

while ($category = mysql_fetch_array($subject_set))
	{
		echo "<ul class='cat_set'>";
		echo "<li>{$category["menu_name"]} </li> </ul>";
//creat sub-category
	$sub_category_query= "SELECT * FROM sub_subjects WHERE subject_id = {$category["id"]}";
	$sub_category_set=mysql_query($sub_category_query, $connect);
if(!$sub_category_set)
{
	die("Database Query Failed: ". mysql_error());
}
while ($sub_cat= mysql_fetch_array ($sub_category_set))
	{
	echo"<ul class='sub_menu'>";
	echo"<li>{$sub_cat["menu_name"]}</li></ul>";
	
	
}
}
}

?>[/php]

I want to be able to continue the list with the “subjects” for each category. I’ll use jewelry as an example… Jewelry-> Jewelry Type -> Metal Used… Like Jewelry ->Necklaces -> Gold.

When I try to add the subjects into the bottom while loop it either doesn’t run or it will break my loop all together. What would I have to do in order to continue the loop to list the subjects and possibly sub-subjects?

Sponsor our Newsletter | Privacy Policy | Terms of Service