PHP MySQL Get column names While iterating through all records
You can use foreach loop
$query = mysql_query("SELECT * FROM mytable");
while ($row = mysql_fetch_assoc($query)) {
foreach($row as $key => $value) {
print "$key = $value <br />";
}
}