Name
mysql_num_fields( )
Synopsis
mysql_num_fields(results
)
This returns the number from fields of the results set given.
... $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"; } ...
As this
example shows, mysql_num_fields( )
can be useful
in conjunction with other functions. Here a list of fields for a
table is retrieved using mysql_list_fields( )
. In
order to help the code display the names of the fields using a
for
statement, the number of fields needs to be
determined. The mysql_num_fields( )
function is
handy for figuring out this bit of information.
Get MySQL in a Nutshell 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.