你可以在mysql中做到这一点mysql_field_name()
不鼓励使用 ,mysql_*
因此请使用pdo
或mysqli
和他们一起你可以做到这一点
mysqli_fetch_field_direct() //for mysqli
PDOStatement::getColumnMeta() //for pdo
例如在OP评论之后
$sql = "SELECT * from Person";
$result = mysql_query($sql,$con);
$name = mysql_field_name($result, 0);
说明如何使用mysql_field_name()
合成纤维
mysql_field_name(data,fieldOffset)
+------------+------------------------------------------------------------------+
| data | Required. Specifies which data pointer to use. The data |
| | pointer is the result from the mysql_query() function |
+------------+------------------------------------------------------------------+
|fieldOffset |Required. Specifies which field to start returning. 0 indicates |
| |the first field |
+------------+------------------------------------------------------------------+
好读
MySQL 开发人员的 PDO 教程