(PHP 4, PHP 5)
mysql_field_name — 결과로부터 특정 필드의 이름을 반환
$result
, int $field_offset
)mysql_field_name()는 특정 필드 이름을 반환한다.
result
mysql_query() 호출을 통한 결과 resource.
field_offset
The numerical field offset. The
field_offset
starts at 0. If
field_offset
does not exist, an error of level
E_WARNING
is also issued.
성공하면 특정 필드 이름을, 실패하면 FALSE
를 반환한다.
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');
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:
하위 호환을 위하여, 다음의 권장하지 않는 별칭을 사용할 수 있습니다: mysql_fieldname()