PHP get field Number implementation Tips _php Tutorial

Source: Internet
Author: User
We pass on

The Mysql_num_fields () function can count the number of all fields in the table that will be queried, and the syntax of the function is as follows:

int Mysql_num_fields (Resource $result)

Where the parameter result is the result set returned after the mysql_query () function executes. 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 ("Connection Server failed");
  3. mysql_select_db ("Sunyang", $connection)
    Or Die ("Select Database Failed");
  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 implementation of the number of PHP get fields.


http://www.bkjia.com/PHPjc/445926.html www.bkjia.com true http://www.bkjia.com/PHPjc/445926.html techarticle we can count the number of all fields in the table to be queried by the Mysql_num_fields () function, which is syntactically formatted as follows: Int Mysql_num_fields (Resource $result) its ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.