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