Name

mysql_field_name

Synopsis

string mysql_field_name(qresource query, int attribute)

Returns the name of an attribute in a result set. The first parameter is a query resource handle returned from a prior call to mysql_list_fields( ), mysql_query( ), or mysql_unbuffered_query( ). The second argument is the ordinal number of the attribute in the SQL query. The first attribute is numbered zero.

Example

<?php
  $connection = mysql_connect("localhost", "fred", "shhh");
  
  $result = mysql_list_fields("wedding", "presents");
  
  echo "The attributes of presents are: ";
  for($x=0; $x < mysql_num_fields($result); $x++)
     echo mysql_field_name($result, $x) . " ";
?>

Get Managing & Using MySQL, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.