You can use the `mysql_fetch_field()` function in PHP to retrieve the structural attributes of a field in a database table.
Example usage:
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$result = mysql_query("SELECT * FROM Persons");
while ($fieldinfo = mysql_fetch_field($result))
{
echo $fieldinfo->name;
echo $fieldinfo->max_length;
echo $fieldinfo->type;
}
mysql_close($con);This code can be retrieved. Persons The names, maximum lengths, and data types of all fields in the table.