-1
I need to fill a table in my HTML page with data returned from a database query.
The problem is that the TABLE tag fills in line by line, from left to right.
In the layout I need to use, I need each row of the returned array to fill a column.
Detail, I need to use the TABLE tag because I need to print this in excel later.
echo "<table>";
while ($temp = $registros-> fetch_assoc()){
echo "<tr>";
foreach ($temp as $mes){
echo "<th>".$mes."</th>";
}
echo "</tr>";
}
echo "</table>";
Query return:
Array ( [Month] => January [col1] => 30 [col2] => 25)
Array ( [Month] => February [col1] => 30 [col2] => 25)
Array ( [Month] => March [col1] => 30 [col2] => 25)