Help with my nested while loops

Hello, im new to the forum and PHP in general and could use some help with my nested while loops.
I am working on an organization chart, pulling names and titles from a database and placing them appropriately based on the current supervisor. Needless to say it will require multiple nested loops. Here is what i have so far:
[php]

<?php require("http://www.trutechunlimited.com/orgchart/_include/constants.html"); $connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS); if (!$connection){ die("Failed to connect to mysql"); } $db_select = mysql_select_db("kirklog1_orgchart", $connection); if (!$db_select) { die("Failed to connect"); } ?> Org-Chart
            <!--this selects the table and stores it as the variable content_set -->
           <?php 
            $query = "SELECT * 
						FROM orgchart";				  
            $content_set = mysql_query($query, $connection);
			
            ?>

            <!--content output starts here-->
            
            <?php
				$content = mysql_fetch_array($content_set);
					
					if ($content['supername'] == "none") {
						echo   "<div id='outer_bubble'>
								<div id='bubble'> " . 
								$content['name'] .
						     	"<br />
								{$content['title']} <br />
								</div><br />";
								$parent1 = $content['name'];
								$content = mysql_fetch_array($content_set);

								while (($content['supername'] == $parent1) && ($parent2 != $content['name'])) {
									echo   "<div id='outer_bubble'>
											<div id='bubble'> " . 
											$content['name'] .
											"<br />
											{$content['title']} <br />
											</div>";
											$parent2 = $content['name'];
											$content = mysql_fetch_array($content_set);
											
							//HERE IS WHERE THE OUTPUT FAILS
											while (($content['supername'] == $parent2) && ($parent3 != $content['name'])) {
												echo   "<div id='outer_bubble'>
														<div id='bubble'> " . 
														$content['name'] .
														"<br />
														{$content['title']} <br />
														</div>";
														$parent3 = $content['name'];
														$content = mysql_fetch_array($content_set);
											
										}
								}

						
					}
            
			?>
     
	</body>
<?php mysql_close($connection); ?>


[/php]

It outputs up until the point where i have commented and said //HERE IS WHERE THE OUTPUT FAILS.

The previous loops function as intended but when i go to output the third layer i receive no output
(No errors, and everything else loads fine)

Kind of complex so if you need more info please ask, i really want to work this one out.
Thanks!
-Kirk

That very first one has to be in a loop, else its just going to look at 1 record.

Sponsor our Newsletter | Privacy Policy | Terms of Service