<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.11 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-field-name">
 <refnamediv>
  <refname>mysql_field_name</refname>
  <refpurpose>
   Get the name of the specified field in a result
  </refpurpose>
 </refnamediv>
 <refsect1>
  <title>Description</title>
   <methodsynopsis>
    <type>string</type><methodname>mysql_field_name</methodname>
    <methodparam><type>resource</type><parameter>result</parameter></methodparam>
    <methodparam><type>int</type><parameter>field_index</parameter></methodparam>
   </methodsynopsis>
  <para>
   <function>mysql_field_name</function> returns the name of the
   specified field index. <parameter>result</parameter> must be a
   valid result identifier and <parameter>field_index</parameter> is
   the numerical offset of the field.
  </para>
  <note>
   <para>
    <parameter>field_index</parameter> starts at 0.
   </para>
   <para>
    e.g. The index of the third field would actually be 2, the index
    of the fourth field would be 3 and so on.
   </para>
  </note>
  &database.field-case;
  <para>
   <example>
    <title><function>mysql_field_name</function> example</title>
    <programlisting role="php">
<![CDATA[
<?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);
?>
]]>
    </programlisting>
    <para>
     The above example would produce the following output:
    </para>
    <screen>
<![CDATA[
user_id
password
]]>
    </screen>
   </example>
  </para>
  <para>
   For downwards compatibility <function>mysql_fieldname</function>
   can also be used. This is deprecated, however.
  </para>
 </refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->