MySQL database function details (3) (11) object mysql_fetch_field (int result [, int col_num]);
Returns the metadata information of the given column in The Returned result set. if such a column is not found, false is returned. If col_num is omitted, the subsequent call to mysql_fetch_field () will return the information of the subsequent columns in the result set. If no more columns exist. The returned value is false. If col_num is specified, the value range is 0 to mysql_num_fields ()-1. In this case, mysql_num_fields () returns information about the given column. if col_num is out of the range, false is returned.
$ Link = mysql_pconnect ("localhost", "sunsoft", "suixiang ")
Or die ("cocould not connect ");
Mysql_select_db ("stamp_db") or die ("cocould not select database ");
$ Query = "SELECT * FROM president ";
$ Result = mysql_query ($ query) or die ("Query failed ");
For ($ I = 0; $ I
{
Printf ("information for column % d:
", $ I );
$ Meta = mysql_fetch_field ($ result );
If (! $ Meta)
{
Print ("No information available
");
Continue;
}
Print ("
");
Printf ("blob: % s
", $ Meta-> blob );
Printf ("max_length: % s
", $ Meta-> max_length );
Printf ("multiple_key: % s
", $ Meta-> multiple_key );
Printf ("name: % s
", $ Meta-> name );
Printf ("not_null: % s
", $ Meta-> not_null );
Printf ("numeric: % s
", $ Meta-> numeric );
Printf ("primary_key: % s
", $ Meta-> primary_key );
Printf ("table: % s
", $ Meta-> table );
Printf ("type: % s
", $ Meta-> type );
Printf ("unique_key: % s
", $ Meta-> unique_key );
Printf ("unsigned: % s
", $ Meta-> unsigned );
Printf ("zerofill: % s
", $ Meta-> zerofill );
Print ("
");
}
?>