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:
< php
$Connection=mysql_connect("localhost",
"Root", "root") or Die ("Connection Server failed");
mysql_select_db ("Sunyang", $connection)
Or Die ("Select Database Failed");
$Query="SELECT * from employee";
$Result=mysql_query($query) or Die
("Query data Failed"); Execute Query
Echo Mysql_field_len ($result, 0);
The length of the first field
Echo Mysql_field_len ($result, 1);
The length of the second field
Echo Mysql_field_len ($result, 2);
The length of a third field
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, 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 ...