mysql_field_name()
string mysql_field_name(results,index)
This function returns the name of a field from the results set given. To specify a particular field, the index of the field in the results set is given as the second argumentā0 being the first field. Here is an example:
...
$sql_stmnt = "SELECT * FROM workreq LIMIT 1";
$results = mysql_query($sql_stmnt);
$num_fields = mysql_num_fields($results);
for ($index = 0; $index < $num_fields; $index++) {
$field_name = mysql_field_name($results, $index);
print $field_name . "\n";
}
...The SQL statement here selects one row from the table. Then
mysql_num_fields() examines the results of
the query and determines the number of fields. The loop processes each
field, starting with field 0 using the
mysql_field_name() function to extract each
field name. The second argument is changed as the
$index variable is incremented with each
loop.