Name
mysql_list_fields( )
Synopsis
mysql_list_fields(database,table[,connection])
This returns a results set containing information about the columns
of a table given for a database specified. The
mysql_field_flags( ), mysql_field_len(), mysql_field_name( ), and
mysql_field_type( ) functions can be used to
extract information from the results set. An identifier may be given
as a third argument to the function to retrieve information for a
different MySQL connection.
...
$fields = mysql_list_fields('workrequests', 'workreq');
$num_fields = mysql_num_fields($fields);
for ($index = 0; $index < $num_fields; $index++) {
print mysql_field_name($fields, $index) . "\n";
}
...After connecting to MySQL, in the first line the example uses
mysql_list_fields( ) to retrieve a list of column
names from the database and table given as arguments. To assist the
for statement that follows, the
mysql_num_fields( ) function determines the number
of fields in the results set, returning a field for each column. Then
PHP loops through the for statement for all the
fields and displays the name of each column using
mysql_field_name( ). Here are a few lines from the
output of this script:
wrid wr_date clientid ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access