Get column name, type and max length
<?php
mysql_connect("mysql153.secureserver.net","java2s","password");
mysql_select_db("java2s");
$query = "SELECT * FROM Employee LIMIT 1";
$result = mysql_query($query);
$fields = mysql_num_fields($result);
for($count=0;$count<$fields;$count++) {
$field = mysql_fetch_field($result,$count);
echo "<p>$field->name $field->type ($field->max_length)</p>";
}
?>
Related examples in the same category