We can count the number of all fields in the table to be queried through the
mysql_num_fields() function. The syntax format of this function is as follows:
int mysql_num_fields (resource $result)
The parameter result is the result set returned after the mysql_query() function is executed. The sample code for getting the number of fields in PHP using the mysql_num_fields() function is as follows:
- < ?php
- $connection=mysql_connect("localhost",
"root","root") or die("Failed to connect to server"); - mysql_select_db("sunyang",$connection)
or die("Failed to select database"); - $query="select * from employee";
- $result=mysql_query($query) or
die("Query data failed"); / /Execute query - echo mysql_num_fields($result);
//Number of output fields - mysql_free_result($result);
- mysql_close();
- ?> >The above is an introduction to the relevant implementation methods of obtaining the number of fields in PHP.
http://www.bkjia.com/PHPjc/445926.html
www.bkjia.com
truehttp: //www.bkjia.com/PHPjc/445926.htmlTechArticleWe can count the number of all fields in the table to be queried through the mysql_num_fields() function. The syntax of this function The format is as follows: int mysql_num_fields ( resource $result ) which...