This prints out a simple table with field name and type. $show_sql = "SHOW FIELDS FROM table_name"; echo "<table>"; $show_result = mysql_query($show_sql); while($s_row = mysql_fetch_array($show_result)) { echo "<tr><td style='width:50pt'><b>$s_row[0]</b><td>$s_row[1]</tr>"; } echo "</table>"; PHP:
to print field names just use: $sql = "SELECT * FROM sometable"; $result = mysql_query($sql); if (mysql_num_rows($result)){ $columns = mysql_num_fields($result); for($i = 0; $i < $columns; $i++) { echo mysql_field_name($result,$i).", "; } } PHP: well this is usefull if you do not want to get another query to the database so you can get the field names and then can print the actual results like you do nomaly.