update : 2015.11.03
php.shukuma.com

검색:
 
 
결과로부터 특정 필드의 이름을 반환

mysql_field_name

(PHP 4, PHP 5)

mysql_field_name결과로부터 특정 필드의 이름을 반환

설명

string mysql_field_name ( resource $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($res0) . "\n";
echo 
mysql_field_name($res2);
?>

위 예제의 출력:

user_id
password

주의

Note: 이 함수가 반환하는 필드 이름은 대소문자를 구별합니다.

Note:

하위 호환을 위하여, 다음의 권장하지 않는 별칭을 사용할 수 있습니다: mysql_fieldname()

참고