HormonX
08-02-2002, 05:50 PM
here is my question .... this might be a bit confusing so please be patient :)
what am doing is using while loop to display data from the database, in this case they are categories. the code for this is below...
<?
include ('connect.php');
$query = "SELECT DISTINCT cat FROM product";
$result = mysql_query( $query, $link );
while($r=mysql_fetch_array($result))
{
$cat=$r['cat'];
printf ("<span class='body'><b> $cat </b><br><br></span>");
}
mysql_free_result($result);
mysql_close($link);
?>
this works fine ... it lists the categories in this fasion;
Category1
Category2
Category3 and so on ...
what i want to do is to list also subcategories in in this fasion;
Category1
SubCategory1-1, Subcategory1-2
Category2
SubCategory2-1, Subcategory2-2
Category3
SubCategory3-1, Subcategory3-2
Do i have to use another while loop to list the subcategories ?
if so where and how do i put there ?
Please help ... :)
thanx in advance .
HormonX
what am doing is using while loop to display data from the database, in this case they are categories. the code for this is below...
<?
include ('connect.php');
$query = "SELECT DISTINCT cat FROM product";
$result = mysql_query( $query, $link );
while($r=mysql_fetch_array($result))
{
$cat=$r['cat'];
printf ("<span class='body'><b> $cat </b><br><br></span>");
}
mysql_free_result($result);
mysql_close($link);
?>
this works fine ... it lists the categories in this fasion;
Category1
Category2
Category3 and so on ...
what i want to do is to list also subcategories in in this fasion;
Category1
SubCategory1-1, Subcategory1-2
Category2
SubCategory2-1, Subcategory2-2
Category3
SubCategory3-1, Subcategory3-2
Do i have to use another while loop to list the subcategories ?
if so where and how do i put there ?
Please help ... :)
thanx in advance .
HormonX