# This should also give you an array of column names
$res = mysql_query("SHOW COLUMNS FROM `my_table`");
while ($row = mysql_fetch_array($res)) $col_names[]=$row[0];
![]() | mysql_list_fields说明resource mysql_list_fields ( string database_name, string table_name [, resource link_identifier] )mysql_list_fields() 取得给定表名的信息。参数是数据库名和表名。返回一个结果指针,可以用于 mysql_field_flags(),mysql_field_len(),mysql_field_name() 和 mysql_field_type()。
为向下兼容仍然可以使用 mysql_listfields(),但反对这样做。
![]()
arster
16-Oct-2005 03:05
# This should also give you an array of column names
harryzhong at hotmail dot com
26-Jul-2005 12:27
Here is a simple script get names of columns in an array:
rhyous at yahoo dot com
05-Jun-2005 06:22
To make an array containing the names of a column from a table, you use the following simple script: (Note: using table1 with three columns)
mbevan at marginsoftware dot com
14-Nov-2003 05:40
If you're willing to use a lot of functions to get a little information about fields in a table, this function is for you. If you just want to get all the information you can find, you can use this:
dom at brainwaveuk dot com
19-Jul-2002 10:55
mysql_list_fields() retrieves information about the given table name but you can use something like mysql_fetch_field to retrieve the field names from a result source.
| ![]() |