mysql_field_name

(PHP 3, PHP 4 )

mysql_field_name -- 結果において指定したフィールド名を得る

説明

string mysql_field_name ( resource result, int field_index)

mysql_field_name() は、指定したフィールドの 名前を返します。 result は有効な結果ID、 field_index はフィールドのオフセット数とす る必要があります。

注意 field_index は0から始まります。

例えば、3番目のフィールドの添字は2、4番目のフィールドの添字は3と いったようになります。

例 1 mysql_field_name() の例

// The users table consists of three fields:
//   user_id
//   username
//   password.
$link = mysql_connect('localhost', $user, "secret");
mysql_select_db($dbname, $link)
    or die("Could not set $dbname");
$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() も使用可能です。