mysql_field_name

(PHP 4, PHP 5)

mysql_field_name — Get the name of the specified field in a result

Warning

This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0.
Instead, the MySQLi or PDO_MySQL extension should be used.
See also MySQL: choosing an API guide and
related FAQ for more information.
Alternatives to this function include:

User Contributed Notes 12 notes

This function is slightly stupid to be honest, why not just make an array of field names... You could consolidate the two of these functions that way and it makes it a lot easier to list them when your script is dynamic.

When using aliases, it appears impossible to discover the name of the underlying column.select `ID` as `anAlias` from `aTable` returns 'anAlias' as the mysql_field_name(). I have tried all the mysql_field_xxx() functions and none return the real column name.

simple sql to xml converter works with any sql query and returns the name of the table as the root element "row" as each row element and the names of the columns are your children of row. fully tested.

You could probably elaborate on this by sending a full sql query to this function...but I titled it simple_query() because it doesn't really allow for joins. Never the less, if you want to get a quick array full of a single row result set this is painless: