mysql_fetch_field()

It returns column info from a recordset as an object

MySQL table – Users

+—-+——+
| id | name |
+—-+——+
|  1 | PHP  |
|  2 | JS   |
|  3 | HTML |
|  4 | AS   |
+—-+——+

Example

<?php
mysql_connect(“localhost”, “root”, “password”) or die(mysql_error());
mysql_select_db(“database_name”);
echo “<pre>”;
$userQry = mysql_query(“SELECT * FROM users”);
while($userInfo = mysql_fetch_field($userQry)){
print_r($userInfo);
}
?>

Output

stdClass Object
(
[name] => id
[table] => users
[def] =>
[max_length] => 1
[not_null] => 1
[primary_key] => 1
[multiple_key] => 0
[unique_key] => 0
[numeric] => 1
[blob] => 0
[type] => int
[unsigned] => 0
[zerofill] => 0
)
stdClass Object
(
[name] => name
[table] => users
[def] =>
[max_length] => 4
[not_null] => 1
[primary_key] => 0
[multiple_key] => 0
[unique_key] => 0
[numeric] => 0
[blob] => 0
[type] => string
[unsigned] => 0
[zerofill] => 0
)