(PHP 4, PHP 5)
mysql_field_name — 取锟矫斤拷锟斤拷锟街革拷锟斤拷侄蔚锟斤拷侄锟斤拷锟�
$result
, int $field_index
) : string
mysql_field_name()
锟斤拷锟斤拷指锟斤拷锟街讹拷锟斤拷锟斤拷锟斤拷锟街讹拷锟斤拷锟斤拷result
锟斤拷锟斤拷锟斤拷一锟斤拷锟较凤拷锟侥斤拷锟斤拷锟绞讹拷锟斤拷锟�field_index
锟角革拷锟街段碉拷锟斤拷锟斤拷偏锟斤拷锟斤拷锟斤拷
Note:
field_index
锟斤拷 0 锟斤拷始锟斤拷锟斤拷锟界,锟斤拷锟斤拷锟斤拷锟街段碉拷锟斤拷锟斤拷值锟斤拷实锟斤拷 2锟斤拷锟斤拷锟侥革拷锟街段碉拷锟斤拷锟斤拷值锟斤拷 3锟斤拷锟皆达拷锟斤拷锟狡★拷
Note: 锟剿猴拷锟斤拷锟斤拷锟截碉拷锟街讹拷锟斤拷锟斤拷小写锟斤拷锟斤拷锟斤拷
Example #1 mysql_field_name() 锟斤拷锟斤拷
<?php
/* The users table consists of three fields:
* user_id
* username
* password.
*/
$link = mysql_connect('localhost', "mysql_user", "mysql_password");
$dbname = "mydb";
mysql_select_db($dbname, $link)
or die("Could not set $dbname: " . mysql_error());
$res = mysql_query("select * from users", $link);
echo mysql_field_name($res, 0) . "\n";
echo mysql_field_name($res, 2);
?>
锟斤拷锟斤拷锟斤拷锟接斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�
user_id password
为锟斤拷锟铰硷拷锟斤拷锟斤拷然锟斤拷锟斤拷使锟斤拷 mysql_fieldname()锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷
result
resource 锟酵的斤拷锟斤拷锟斤拷锟斤拷私锟斤拷锟斤拷锟斤拷锟皆讹拷 mysql_query() 锟侥碉拷锟矫★拷
field_offset
锟斤拷值锟斤拷锟街讹拷偏锟斤拷锟斤拷锟斤拷
field_offset
锟斤拷 0 锟斤拷始锟斤拷锟斤拷锟�
field_offset
锟斤拷锟斤拷锟节o拷锟斤拷岱拷锟揭伙拷锟�
E_WARNING
锟斤拷锟斤拷拇锟斤拷锟�
The name of the specified field index on success 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE
.
Example #2 mysql_field_name() example
<?php
/* The users table consists of three fields:
* user_id
* username
* password.
*/
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect to MySQL server: ' . mysql_error());
}
$dbname = 'mydb';
$db_selected = mysql_select_db($dbname, $link);
if (!$db_selected) {
die("Could not set $dbname: " . mysql_error());
}
$res = mysql_query('select * from users', $link);
echo mysql_field_name($res, 0) . "\n";
echo mysql_field_name($res, 2);
?>
锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�
user_id password
Note: 锟剿猴拷锟斤拷锟斤拷锟截碉拷锟街讹拷锟斤拷锟斤拷小写锟斤拷锟斤拷锟斤拷
Note:
为锟斤拷锟斤拷锟铰硷拷锟捷o拷锟斤拷锟斤拷使锟斤拷锟斤拷锟斤拷锟窖凤拷锟斤拷锟侥憋拷锟斤拷锟斤拷 mysql_fieldname()