PHP get field length correlation function usage Tips

Source: Internet
Author: User

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<?PHP2 $connection=mysql_connect("localhost",3"Root", "root") or die("Connection Server failed"); 4 mysql_select_db("Sunyang",$connection)5Or die("Select Database Failed"); 6 $query= "SELECT * FROM Employee"; 7 $result=mysql_query($query) or die8("Query data Failed");//Execute Query9 Echo Mysql_field_len($result, 0); Ten //the length of the first field One Echo Mysql_field_len($result, 1);  A //the length of the second field - Echo Mysql_field_len($result, 2);  - //the length of a third field the Echo Mysql_field_len($result, 3); -  //length of the fourth field - Mysql_free_result($result);  - Mysql_close();  +?>

The above is the PHP get field length related methods explained.

PHP get field length correlation function usage Tips

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.