Forum und email

mysql_field_name

(PHP 4, PHP 5, PECL mysql:1.0)

mysql_field_name — Get the name of the specified field in a result

Popis

string mysql_field_name ( resource $result , int $field_offset )

mysql_field_name() returns the name of the specified field index.

Parametre

result

Výsledný resource, ktorý je vyhodnocovaný. Tento výsledok pochádza z volania mysql_query().

field_offset

Ofset číselného poľa. Field_offset začína na 0. Ak field_offset neexistuje, je tiež vytvorený error úrovne E_WARNING.

Vrátené hodnoty

The name of the specified field index on success, or FALSE on failure.

Príklady

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

Výstup horeuvedeného príkladu bude:

user_id
password

Poznámky

Note: Pole názvov vrátené touto funkciou sú case-sensitive.

Note: Pre spätný kompatibilitu, nasledujúci zastaraný alias môže byť použitý: mysql_fieldname()