Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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>

<?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) ); ?>

<?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;?>
</div><!--End category-->
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 03:52 PM.

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