mysql_num_fields
(PHP 4, PHP 5, PECL mysql:1.0)
mysql_num_fields — Get number of fields in result
說明
int mysql_num_fields
( resource $result
)
Retrieves the number of fields from a query.
Return值
Returns the number of fields in the result set resource on success, or FALSE on failure.
範例
Example#1 A mysql_num_fields() example
<?php
$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
/* returns 2 because id,email === two fields */
echo mysql_num_fields($result);
?>
註釋
Note: 為了保證向下相容性,可以使用下面的別名,但不贊成使用它: mysql_numfields()