nested do while within php script to populate html menu
So, I have a html menu that is generated from two tables within a database (or at least I would like to accomplish this). One of my table is Primary Categories and the other table is a listing of Secondary Categories. What I want to accomplish is: fore each primary category to print each subcategory. There can be many secondary categories for each primary category. My problem is: my DO WHILE statements never gets beyond the first interation of the results of the second database query.
Any suggestions would be most appreciated.
HTML code is below:
<div id="category" >
<ul >
<li class="section">Product Category</li>
<?php $interationP=0; $interationS=0; ?>
<?php do { ?>
<li class=""><a href=""><?php echo $row_get_primary_product_category['primary_product_category_name']; echo "\r\n"; ?></a>
<ul>
<?php do { ?>
<?php $grab_primary_id_from_primary = $row_get_primary_product_category['primary_product_category_id'] ?>
<?php $grab_primary_id_from_secondary = $row_get_secondary_product_category['primary_product_category_id'] ?>
<?php if ($grab_primary_id_from_primary == $grab_primary_id_from_secondary)
echo "\r\n<li> ".$row_get_secondary_product_category['secondary_product_category_name']."</li>\r\n";
?>
<?php } while ($row_get_secondary_product_category = mysql_fetch_assoc($get_secondary_product_category) ); ?>
</ul>
</li>
<?php $interationP++; ?>
<?php } while ($row_get_primary_product_category = mysql_fetch_assoc($get_primary_product_category)); ?>
<?php $interationS++; ?>
<?php echo $interationP; echo "x"; echo $interationS;?>
</ul>
</div><!--End category-->
|