Quick Master PHP get field Data type Tips _php Tutorial

Source: Internet
Author: User
For a beginner, they must learn in the course of learning the flexible use of various

The Mysql_field_type () function obtains the data type of the field, and the syntax of the function is as follows.

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

The Mysql_field_type () function is similar to the function mysql_field_name (), but the Mysql_field_type () function returns the data type of the field. The description of its parameters is as follows.

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 using the Mysql_field_type () function is as follows:

Code 23-12 CD Codes 23rd Chapter 23.3mysql_field_type.php

 
 
  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");
  6. Execute Query
  7. Echo Mysql_field_type ($result, 0);
  8. Data type of the first field
  9. echo " < br>";
  10. Echo Mysql_field_type ($result, 1);
  11. Data type of the second field
  12. echo " < br>";
  13. Echo Mysql_field_type ($result, 2);
  14. Data type of the third field
  15. Mysql_free_result ($result);
  16. Mysql_close ();
  17. ?>

The data type of the first 3 fields in the table employee will be output when the above code executes.


http://www.bkjia.com/PHPjc/445931.html www.bkjia.com true http://www.bkjia.com/PHPjc/445931.html techarticle for a beginner, they must learn the flexible use of various mysql_field_type () functions to obtain the data type of the field, the syntax of the function is as follows. ...

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