http://php.net/manual/en/function.mysql-num-fields.php
$result = mysql_query("select * from table");
echo '<tr>';
for ($i = 0; $i < mysql_num_fields($result); $i++) {
echo "<th>".mysql_field_name($result, $i)."</th>";
}
echo '</tr>';
1
solved Gather column name of a table from database [closed]