Have results of query passed through PHP to MySQL which is returned from several hundred rows grouped that gets displayed as a table like Table A (sorry about the line-up):
Table A
ElementA | Topic1 | Topic2 |... several calculated cells, etc.
ElementA | Topic1a| Topic2a|... several calculated cells, etc.
ElementA | Topic1b| Topic2b|... several calculated cells, etc.
ElementB | Topic1a| Topic2c|... several calculated cells, etc.
ElementB | Topic1b| Topic3 |... several calculated cells, etc.
ElementB | Topic1c| Topic3a|... several calculated cells, etc.
ElementB | Topic1d| Topic4 |... several calculated cells, etc.
ElementC | Topic1 | Topic2 |... several calculated cells, etc.
ElementC | Topic1a| Topic2a|... several calculated cells, etc.
ElementC | Topic2 | Topic2b|... several calculated cells, etc.
What I need/want is to have the display like Table B, the ...... are just place holders to show approximate alignment for a couple of the "|Topicxx columns :
Table B
ElementA | Topic1 | Topic2 |... several calculated cells, etc.
............ | Topic1a| Topic2a|... several calculated cells, etc.
............ | Topic1b| Topic2b|... several calculated cells, etc.
ElementB | Topic1a| Topic2c|... several calculated cells, etc.
| Topic1b| Topic3 |... several calculated cells, etc.
| Topic1c| Topic3a|... several calculated cells, etc.
| Topic1d| Topic4 |... several calculated cells, etc.
ElementC | Topic1 | Topic2 |... several calculated cells, etc.
| Topic1a| Topic2a|... several calculated cells, etc.
| Topic2 | Topic2b|... several calculated cells, etc.
The php I am using to return the results in Table A is basic and follows:
PHP
// layout table header
echo "<table border =1>\n";
echo "<tr bgcolor=\"#CCFFCC\" align = center>\n";
echo "<td> </td>\n";
for ($i=0; $i<$number_cols; $i++)
{
echo "<th>" . mysql_field_name($result, $i). "</th>\n";
}
echo "</tr>\n"; //end layout table header
// layout table body
while ($row = mysql_fetch_row($result))
{
$row_color = ($row_count % 2) ? $color1 : $color2;
echo "<tr align = left bgcolor=\"$row_color\">\n";
echo "<td bgcolor=\"$row_color\"> </td>";
for ($i=0; $i<$number_cols; $i++)
{
echo "<td>";
if (!isset($row[$i]))
{echo "NULL";}
else
{echo $row[$i];}
echo "</td>\n";
}
$row_count++;
echo "</tr>\n";
}
echo "</table>";
I would like to keep the table construct dynamic, as different queries can return different numbers of columns.
Suggestions or guidance are greatly appreciated I have been in and out of the manual, code snippets, etc. I am certain there is some simple construct that will allow me to space file, and dynamically display to the next row sets. No success to this juncture.
Thanks,
Tbull