Home > Backend Development > PHP Tutorial > Explanation of implementation techniques for obtaining the number of fields in PHP_PHP Tutorial

Explanation of implementation techniques for obtaining the number of fields in PHP_PHP Tutorial

WBOY
Release: 2016-07-15 13:35:00
Original
1405 people have browsed it

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:

  1. < ?php
  2. $connection=mysql_connect("localhost",
    "root","root") or die("Failed to connect to server");
  3. mysql_select_db("sunyang",$connection)
    or die("Failed to select database");
  4. $query="select * from employee";
  5. $result=mysql_query($query) or
    die("Query data failed"); / /Execute query
  6. echo mysql_num_fields($result);
    //Number of output fields
  7. mysql_free_result($result);
  8. mysql_close();
  9. ?> >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...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template