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

Your name:

Reply:


Posted by Crystal on 06/23/06 00:39

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
help.

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");
makeOrgBox($name,$title,$dept,$level,$orgbox);
}
displaySubordinates($id,$orgbox);
}
return($orgbox);
}

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация