Hi;
Maybe I'm going about this the wrong way, but I've got a MySQL query that seems to put results properly into a multidimensional array. I'm just having problems getting them to display in a table type format.
(The data shows amount of time various people engaged in various activities) I want to use the name as "row" and activity type as "column".
When I include a "print_r" statement in the code, the results show like so:
Array (
[Agnes] => Array ( [PVNT] => 22.75 [EINT] => 9.50 [OTHER] => 2.50 )
[April] => Array ( [PVNT] => 3.50 )
[Bob] => Array ( [PVNT] => 23.42 [EINT] => 2.00 )
[Chris] => Array ( [PVNT] => 49.00 [FINT] => 5.00 [OTHER] => 8.25 )
[Colleen] => Array ( [EINT] => 1.25 [PVNT] => 14.42 [OTHER] => 8.50 )
[Diane] => Array ( [PVNT] => 17.17 [FINT] => 3.50 )
[Jane] => Array ( [PVNT] => 16.25 [EINT] => 8.67 )
[Jane2] => Array ( [OTHER] => 27.75 [PVNT] => 12.00 )
[Janice] => Array ( [PVNT] => 13.08 [FINT] => 1.25 )
[Jennifer] => Array ( [PVNT] => 14.25 [FINT] => 0.50 )
[Judy] => Array ( [FINT] => 7.08 [EINT] => 7.17 [PVNT] => 9.25 )
[Lori] => Array ( [EINT] => 3.00 [PVNT] => 43.00 )
[Lourdes] => Array ( [PVNT] => 37.50 [EINT] => 15.25 )
[Marie] => Array ( [FINT] => 9.00 [PVNT] => 64.08 )
[Nancy] => Array ( [EINT] => 10.00 [OTHER] => 3.50 [PVNT] => 12.00 [FINT] => 1.00 )
[Rae] => Array ( [FINT] => 15.50 [PVNT] => 42.00 [OTHER] => 2.25 [EINT] => 4.50 )
[Rosanne] => Array ( [PVNT] => 14.33 [FINT] => 4.50 )
[Sandra] => Array ( [PVNT] => 16.25 [EINT] => 1.50 )
[Tom] => Array ( [PVNT] => 3.00 [OTHER] => 2.50 [EINT] => 1.50 )
[Travis] => Array ( [PVNT] => 16.67 [EINT_] => 11.50 [OTHER] => 4.00 )
)
Let's call the multidimensional array "$WorkArray"
The values for NAMES are pretty obvious, the strings like PVNT, EINT, FINT_, and OTHER represent the TYPE OF WORK and the numbers represent TIME.
I'm having a bit of trouble getting the data to display in an html table. I have been working pretty much with one-dimensional arrays, but putting a second dimension in has me pretty confused.
the code I've written to make the data rows goes like this:
//RUN QUERY AGAIN TO GET DATA
while ($Row = mysql_fetch_array($resultFACILITATOR))
{
$WorkArray[$Row['NAME']][$Row['CODE']] = $Row[HOURS];
}
foreach ($WorkArray as $key => $value) {
print "<tr><td>$key</td><td>$WorkArray[$key][PVNT_]</td><th>$WorkArray[$key][EINT_]</th><th>$WorkArray[$key][FINT_]</th><th>$WorkArray[$key][OTHER]</th></tr>\n";
}
The names show up in the Names column, but values for the work-type columns are not right...Each cell says something like "Array[PVNT_]" etc.
Seems like I'm not too far off? But I need a clue.
Thanks