$sql = "SELECT * from person", $result = mysql_query ($sql, $con) and while ($property = Mysql_fetch_field ($result)) {echo "Fi Eld name: ". $property->name. "<br/>"; echo "Table name:". $property->table. "<br/>"; echo "Default value:". $property->def. "<br/>"; echo "Max length:". $property->max_length. "<br/>"; echo "Not NULL:". $property->not_null. "<br/>"; echo "Primary Key:". $property->primary_key. "<br/>"; echo "Unique Key:". $property->unique_key. "<br/>"; echo "mutliple Key:". $property->multiple_key. "<br/>"; echo "Numeric Field:". $property->numeric. "<br/>"; echo "BLOB:". $property->blob. "<br/>"; echo "Field Type:". $property->type. "<br/>"; echo "Unsigned:". $property->unsigned. "<br/>"; echo "zero-filled:". $property->zerofill. "<br/><br/>"; }
Key fields:
echo "Primary Key:". $property->primary_key. "<br/>";
PHP query MySQL table's primary key