Proper application of function to implement PHP get table field name _php Tutorial

Source: Internet
Author: User
In the application

The PHP Get table field name is implemented by the Mysql_field_name () function, which has the following syntax format:

String Mysql_field_name (resource $result, int $field _offset)

The Mysql_field_name () function returns the name of the field for the specified index, and its parameters are described below.

L Result:mysql_query () The result set returned after the function is executed.

L Field_offset: The offset of the field with a starting value of zero.

The example code for getting table field names using PHP with the Mysql_field_name () 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 user failed");
  6. Echo mysql_field_name ($result, 0);
    Output first field name
  7. echo " <br> ";
  8. Echo Mysql_field_name ($result, 1);
    Output second field name
  9. Mysql_close ($connection);
  10. ?>

The first field name and second field name can be output in the PHP Get table fields name code above.


http://www.bkjia.com/PHPjc/445930.html www.bkjia.com true http://www.bkjia.com/PHPjc/445930.html techarticle using PHP to get the table field name is implemented by the Mysql_field_name () function, which has the following syntax format: String mysql_field_name (Resource $result, int $field _offset) Mysql_fie ...

  • 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.