PHP mysql_num_fields() Function
Definition and Usage
The mysql_num_fields() function returns the number of fields in the result set.
Returns false if it fails.
Syntax
mysql_num_fields(data)
Parameter | Description |
---|---|
data | Required. Specifies the data pointer to be used. This data pointer is the result produced by the mysql_query() function. |
Example
<?php $con = mysql_connect("localhost", "hello", "321"); if (!$con) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db("test_db",$con); $sql = "SELECT * FROM person"; $result = mysql_query($sql,$con); echo mysql_num_fields($result); mysql_close($con); ?>
Output similar to:
3