I’m trying to render 4 columns from a mysql query but I cannot properly align the output values, how can I format the table, so all 4 columns and headers to align center?
$tableStyle = "padding: 5px;border:1px";
$tdStyle = "padding:5px ";
echo '<table style="' . $tableStyle . '" cellpadding="5" cellspacing="5">';
echo "<tr align='center'> <th>Title</th><th>Score</th><th>Maximum Score</th><th>Finished On</th></tr>";
$row = $database->loadRowList();
foreach($row as $valuearray)
{
echo '<tr style=" align="center">';
foreach($valuearray as $field)
{
echo "<td align='center'>$field</td>";
}
echo "</tr>";
}
echo "</table>";
Wrap your table with data with in another table which has one cell and center it so that the HTML looks something like this: