Hi,
I've gotten help with writing this in another thread, but I'm having a problem with the code. After reading the data from the db, I create the table. Everything works except the individual values are never written into the table. I know they exists in the $var array from the test I run at the end. The nested foreach seems to be where the problem lies. Any help would be appreciated.
$col=array("TTC","OTC","OVID","N");
$t_row=array("TROUBLE", "ORDERS");
$var=array();
while ($row = mysql_fetch_assoc($result))
{
$assign=$row['Assign'];
$location=$row['Ft_location'];
$var[$assign][$location][]=$row['Tech']; // fill the $var arrary
}
//Print the headers
print "<table border=\"1\" width=\"80%\">"; // change
print "<tr>";
print "<th> </th>";
foreach( $col AS $c )
{
print "<th width=\"25%\">$c</th>";
}
print "</tr>";
//Print the results
foreach( $t_row AS $r )
{
print "<tr><td>$r</td>";
foreach( $col AS $c )
{
if ( !empty( $var[$c][$r] ) )
printf( "<td>%s</td>" , implode( "<br />" , $var[$c][$r] ) );
else
print "<td> </td>";
}
print "</tr>";
}
// end the table
print "</table>";
// data test
print "<pre>";
print_r($var);
print "</pre>";
// disconnect
mysql_close($connect);
}
?>
Thanks,
noah_count