Wade Smart wrote:
> 
> 
> 20080819 1406 GMT-6
> 
> Im still working on fixing a bunch of code for the local school district.
> Without going into detail here, I need to get the name of a field in a 
> row of
> data from the db. I found the mysql_field_name() function but what it 
> returns is
> what is IN the field, not the name of the field.
> 
> So if I was calling say "Michelle" from LAST_NAME I would expect to see
> LAST_NAME as the result of mysql_field_name($result,0);
> 
> Wade

I believe mysql_fetch_assoc() will do what you need. It will return an 
array of your query result keyed by db column.

For instance:

$query = "SELECT * FROM mytable";
$row = mysql_fetch_assoc($query);
print_r($row);

~result~
array(
   'first_name' = 'Michelle',
   'last_name' = 'Smith'
)

Reply via email to