This seems like such a stupid little problem, but it's been bugging me
for hours now. I have a 2D array called agents2d. I need to loop
through it and display the info. Here is my code:
echo "<TABLE BORDER=\"1\" ALIGN=\"center\">\n";
echo "<TR><TD COLSPAN=\"4\"
ALIGN=\"center\">$queue_name_line</TD></TR>\n";
echo "<TR><TD COLSPAN=\"4\"> </TD></TR>\n";
echo "<TR><TH>Agent #</TH><TH>Status</TH><TH>Calls Taken</TH><TH>Secs
since last call</TH></TR>\n";
foreach($agents2d as $value){
echo
"<TR><TD>$value[0]</TD><TD>$value[1]</TD><TD>$value[2]</TD><TD>$value[3]</TD></TR>";
}
echo "</TABLE>";
When I display this code, the lines in the loop come out staggered ..
kinda like this:
1345
statusA
45
445
1346
statusB
56
778
etc...
I also tried this:
echo "<TABLE BORDER=\"1\" ALIGN=\"center\">\n";
echo "<TR><TD COLSPAN=\"4\"
ALIGN=\"center\">$queue_name_line</TD></TR>\n";
echo "<TR><TD COLSPAN=\"4\"> </TD></TR>\n";
echo "<TR><TH>Agent #</TH><TH>Status</TH><TH>Calls Taken</TH><TH>Secs
since last call</TH></TR>\n";
foreach($agents2d as $value1){
echo "<TR>";
foreach($value1 as $value2){
echo "<TD>$value2</TD>";
}
echo "</TR>\n";
}
echo "</TABLE>\n";
.... but all the info showed up in the first column only.
1345
statusA
45
455
1346
statusB
35
667
This seems like such a stupid thing. Almost like I'm missing something
in the HTML. But, maybe I just don't quite understand looping over a
2d array.
What am I doing wrong?