view raw
mrdarb mrdarb - 6 months ago 29
HTML Question

Table headers in the wrong direction

I'm currently trying to populate home HTML tables with some arrays in PHP, my HTML knowledge is far from sufficient and I was wondering if someone could help me with getting the table headers to go horizontally rather than vertically?

PHP:

print "<table>";
print "<tr>";
for ($x=0; $x <=10; $x++)
{
print "</tr>";
print "<th>$keys[$x]</th>";
print "<td>$step[$x]</td>";
}


OUTCOME:

These are the headers that I want to be displayed horizontally rather than vertically..

Any help appreciated as always, thanks

enter image description here

Answer

First make a row with headers, after that a row with the values.

print "<table>";
print "<tr>";
    for ($x=0; $x <=10; $x++)
    {
        print "<th>$keys[$x]</th>";
    }
print "</tr>";
print "<tr>";
    for ($x=0; $x <=10; $x++)
    {
        print "<td>$step[$x]</td>";
    }
print "</tr>";