PHP get field length correlation function using tips _php tutorial

Source: Internet
Author: User
php Get field length correlation function using tips _php tutorial

As a qualified

When you design a database, the length of each field is not exactly the same because each field represents a different meaning of the data. In PHP, the use of the Mysql_field_len () function enables PHP to get the field length, which has the following syntax format:

int Mysql_field_len (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 getting the field length using PHP mysql_field_len () 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_len ($result, 0);
    The length of the first field

  7. Echo Mysql_field_len ($result, 1);
    The length of the second field

  8. Echo Mysql_field_len ($result, 2);
    The length of a third field

  9. Echo Mysql_field_len ($result, 3);
    Length of the fourth field

  10. Mysql_free_result ($result);

  11. Mysql_close ();

  12. ?>


The above is the PHP get field length related methods explained, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!



http://www.bkjia.com/PHPjc/445927.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445927. Htmltecharticle as a qualified in the design database, the length of each field will not be exactly the same because each field represents a different meaning of the data. In PHP, use mysql_field_le ...

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