didn't read the question properly.
to store the fieldnames in an array:
<?
mysql_connect('somehost','root','pass');
$str_SQL= "SELECT * FROM tblname";
$result = mysql_db_query("dbname", $str_SQL);
$numfields = mysql_num_fields($result);
for($i = 0; $i < $numfields; $i++)
{
$str_Fields[]=mysql_field_name($result,$i).",";
}
?>