Name

mysql_list_fields

Synopsis

qresource mysql_list_fields(string database, string table[, cresource connection])

Returns a query resource handle that can be used to retrieve information about the attributes of the specified table within the given database. The attribute information can be retrieved through the functions mysql_field_name( ), mysql_field_type( ), mysql_field_len( ), and mysql_field_flags( ). An optional connection resource handle may be provided as the third parameter; otherwise, the most recently opened connection that is still open is assumed.

Returns false on failure.

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.