Get column name, type and max length : Table MetaData « MySQL Database « PHP






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

1.Get table column flag
2.Get column data type
3.Get field length
4.Total number of fields in a table