OOP: Function in a Function
Posted: Sat Apr 26, 2008 11:55 am
I have a loop nested in a loop in order to create columns and rows in a table. I'm turning the code below into a class.
I want to turn both the row and the column loop into their own, separate, functions. So, my questions is, in a class, how do you call one function from inside another?
I want to turn both the row and the column loop into their own, separate, functions. So, my questions is, in a class, how do you call one function from inside another?
Code: Select all
while(list($l_id,$l_name)=mysql_fetch_array($rowResult)){
$row.= "<tr valign=\"top\">\n";
$row.= "<td width=\"20%\">Level $l_name</td>\n";
$colQuery="SELECT d_id, d_name FROM discipline ";
if($discipline!=NULL){
$colQuery.="WHERE d_id=$discipline ";
}
$colQuery.="ORDER BY d_id ASC";
$colResult=mysql_query($colQuery) or die ("<strong>Level Error:</strong> ".mysql_error());
while(list($d_id,$d_discipline)=mysql_fetch_array($colResult)){
$row.= "<td class=\"inside\">\n";
$empQuery="SELECT e_id, e_fname, e_lname, e_performance FROM employee ";
$empQuery.="WHERE e_discipline=$d_id AND e_level=$l_id ";
if($office != NULL){
$empQuery.="AND e_office=$office ";
}
$empQuery.="ORDER BY e_performance,e_title,e_lname ASC";
$empResult=mysql_query($empQuery) or die ("<strong>Employee Error:</strong> ".mysql_error());
while(list($e_id,$fname, $lname,$e_performance)=mysql_fetch_array($empResult)){
$row.= " <a class=\"info\" href=\"index.php?page=profile&id=$e_id\"><img title=\"{$fname} {$lname}\" src=\"images/rating/$e_performance.png\" /></a> ";
}
}
}