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