mysql_num_fields

int mysql_num_fields(mysql result result_handle) 

Gets the number of fields in a MySQL result handle.

Returns:

Integer; NULL on error

Description:

mysql_num_fields() returns the number of fields that exist in each row of a MySQL result handle.

Version:

PHP 3+, PHP 4+

See also:

To find the number of rows in a result handle:

mysql_num_rows() 

Example:

Find out how many fields of data exist within a row
 <?php // Included code that connects to a MySQL server and sets a default database // See the MySQL Functions chapter introduction for the source code for the file include ('mysql_connect.inc.php'); // Get the current time and UNIX timestamp $query = "SELECT * FROM user"; // Suppress errors for each line below with a single at ...

Get PHP Functions Essential Reference 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.