PHP.nl

mysql_field_name

mysql_field_name

Get the name of the specified field in a result

Waarschuwing: > mysqli_fetch_field_direct``PDOStatement::getColumnMeta

 **mysql_field_name** resource $result int $field_offset
returns the name of the

specified field index. mysql_field_name

The name of the specified field index on successreturn.falseforfailure.

Voorbeeld: 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

Opmerking: > info.deprecated.alias

mysql_fieldname

mysql_field_type``mysql_field_len