Here is a PHP code in order to view table in HTML format from MySql database, As one knows you have to place this code in php tag (<?php … ?>) in order to execute it.
print "<TABLE BORDER=0 CELLPADDING=2>\n";
$fields = mysql_list_fields("DATABASENAME", "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";