MySQL database function details (3) _ MySQL

Source: Internet
Author: User
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 ("

");

}

?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.