Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
| Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 26th, 2013, 03:12 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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-->




Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate Adobe PDF with html form data bfoley Classic ASP Basics 4 January 17th, 2008 09:44 AM
SQL Script to populate TBH database motemape BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 May 25th, 2007 04:42 AM
Populate Select Menu from MySQL Database joviyach PHP Databases 4 June 24th, 2006 09:38 PM
dynamic menu from nested repeaters Jacko ASP.NET 1.0 and 1.1 Professional 1 March 6th, 2006 06:51 AM
Call and run CGI script from a PHP script ... how? dbruins BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 June 10th, 2003 03:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.