mysql-automatic-table.php
<html>
<head>
<title>MySQL - Automatic table columns creation</title>
</head>
<body>
<table border="1" bordercolor="#D3D3D3" cellpadding="0" cellspacing="0">
<?php
$res = mysql_query('SELECT * FROM table') or die(__LINE__.':'.mysql_error());
$header = true;
while($row = mysql_fetch_assoc($res)) {
if($header) {
echo '<tr><th>'.implode('</th><th>', array_keys($row)).'</th></tr>';
$header = false;
}
echo '<tr><td>'.implode('</td><td>', $row).'</td></tr>';
}
?>
</table>
</body>
</html>