PHP MySQL Functions to get the Field length from a result setmysql_field_ln function will return the length of field associated with the field. This command takes one result set as input along with a field identifier or an offset. It returns a string holding field length details. Here is the command.
Please note that the function mysql_field_len is not returning the length of the data stored in the field. It is giving the length of the field assigned in the structure of the table. So our data stored in that field can be less or equal the assigned length of that field. Check the end of this tutorial on how to get length of the data stored in a row.
We will try to develop one script using our student table to display the field length of all the fields.
The above code will display the field type with the fields of the student table.
The result of the above script is here
As you have seen in the above code the length of the field is given but not the length of the data stored in the field. To get the length of data stored in a field we have to use mysql_fetch_lengths function.
This article is written by plus2net.com team.
![]() ![]() | ||