About PHP get Field properties Tips _php Tutorial

Source: Internet
Author: User
In web development, you always encounter database-related operations. As a beginner, this is something that must be mastered. Here's a concrete analysis.

fields, in addition to field names, data types, and lengths, have other properties, such as whether the primary key, whether it is a foreign key, whether it is allowed to be empty, and so on. The PHP Get field property is available through the mysql_field_flags () function, which has the following syntax format:

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

The parameters involved in the above syntax 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 sample code for the PHP Get field property using the Mysql_field_flags () 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_field_flags ($result, 0);
    Properties of the first field
  7. echo " < BR > ";
  8. Echo Mysql_field_flags ($result, 1);
    Properties of the second field
  9. echo " < BR > ";
  10. Echo Mysql_field_flags ($result, 2);
    Properties of the third field
  11. Mysql_free_result ($result);
  12. Mysql_close ();
  13. ?>

These are the tips we've shared about PHP's getting field properties.


http://www.bkjia.com/PHPjc/445928.html www.bkjia.com true http://www.bkjia.com/PHPjc/445928.html techarticle In Web development, you always encounter database-related operations. As a beginner, this is something that must be mastered. The following is a detailed analysis of the field in addition to the field name 、...

  • Related Article

    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.