GD org chart -- image display problem... One function works, the other does not...

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I have created a small program that prints out an organization chart in
PHP using the GD lib's imagecreate, imageline and imagestring
functions.  Basically, a user selects an employee from a drop-down list
to generate an on-the-fly graphical organization tree.  A function is
called to set the selected employee's data into an imagestring and draw
imagelines around it.  Next a recursive function is called to query for
and display all direct reports in a hierarchal tree style format.

The code was working just fine until I separated the logic into two
separate functions.  The problem is that now that I have set up the
code to be a recursive function, the image no longer will display.
When the recursive part of the code (below) is commented out, the first
function works fine.  Both functions call a third function
"makeOrgBox()" to get the x,y positions of all imagestrings and
imagelines for the passed employee so the third function takes the
exact same args.

Anybody know of any issues when looping over results to build
imagestrings and imagelines?  What about problems using the same image
handler in multiple functions?  I am completely stumped since both
functions work independently, but the recursive function will not
produce the imagestrings or the imagelines and all I get is the dreaded
x in the box to indicate a missing image.  Thanks in advance for your

Problem Code Snippet...
function displaySubordinates($id,$orgbox) {
$sqlquery = "SELECT ID,name,title,dept,level FROM employees WHERE
supervisor = '$id'";

$result = mysql_query($sqlquery);
$total_rec = mysql_num_rows($result);
$i = 0;
if ($total_rec > 0)
        // process the results
        for($i=0; $i < $total_rec; $i++){
            $id = mysql_result($result,$i,"id");
            $name = mysql_result($result,$i,"name");
            $title = mysql_result($result,$i,"title");
            $dept = mysql_result($result,$i,"dept");
            $level = mysql_result($result,$i,"level");

function makeOrgBox($name,$title,$dept,$level,$orgbox){
// $orgbox is the image handle

Site Timeline