Here's generic code that will do it:
<?php
print "<TABLE BORDER=0 CELLPADDING=2>\n";
$fields = mysql_list_fields("YOURDATABASENAME", "YOURSQLTABLENAME");
$columns = mysql_num_fields($fields);
print "<TR>";
for ($x = 0; $x < $columns;$x++) {
print "<TH>" . mysql_field_name($fields,$x) . "</TH>\n";
}
print "</TR>\n";
$sql = "SELECT * from YOURSQLTABLENAME";
$result = mysql_query($sql);
while ($obj = mysql_fetch_object($result,MYSQL_ASSOC)) {
print "<TR>";
foreach($obj as $val) {
print "<TD>" . $val . "</TD>";
}
print "</TR>\n";
}
echo "</TABLE>\n";
?>
Obviously, that assumes you already connected to the database with mysql_connect() and selected a database with mysql_select_db().
There are MANY ways to do this sort of thing, of course, and some may be better than others depending on the situation. Some might have used mysql_fetch_row instead of object, which I use habitually. This, anyhow, will print all the field names and fields of any database without you needing to know ahead of time how big it is.