(11) object mysql_fetch_field(int result [,int col_num]);
返回结果集中给定列的相关元数据信息,如果没有这样的列,则返回假。如果省略col_num,则对mysql_fetch_field()的后继调用返回结果集后续列的信息。如果不再有剩余的列。则返回值为假。如果指定了col_num,则其取值范围为0到mysql_num_fields()-1。在此情况下,mysql_num_fields()返回给定列的相关信息,如果col_num超出范围,返回假。
<?php $link=mysql_pconnect("localhost","sunsoft","suixiang") or die("Could not connect"); mysql_select_db("stamp_db") or die("Could not select database"); $query="SELECT * FROM president"; $result=mysql_query($query) or die("Query failed"); for($i=0;$i<mysql_num_fields($result);$i++) { printf("information for column %d:<BR> ",$i); $meta=mysql_fetch_field($result); if(!$meta) { print("No information available<BR> "); continue; } print("<PRE> "); 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("</PRE> "); } ?> |
正在阅读:MySQL数据库函数详解(3)MySQL数据库函数详解(3)
2004-04-01 13:26
出处:奥索网
责任编辑:pjl
键盘也能翻页,试试“← →”键