<HTML ><HEAD ><TITLE >mysql_list_fields</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="MySQL Functions" HREF="ref.mysql.html"><LINK REL="PREVIOUS" TITLE="mysql_list_dbs" HREF="function.mysql-list-dbs.html"><LINK REL="NEXT" TITLE="mysql_list_processes" HREF="function.mysql-list-processes.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.mysql-list-dbs.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.mysql-list-processes.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.mysql-list-fields" ></A >mysql_list_fields</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN59166" ></A ><P > (PHP 3, PHP 4 )</P >mysql_list_fields -- List MySQL result fields</DIV ><DIV CLASS="refsect1" ><A NAME="AEN59169" ></A ><H2 >Description</H2 >resource <B CLASS="methodname" >mysql_list_fields</B > ( string database_name, string table_name [, resource link_identifier])<BR ></BR ><P > <B CLASS="function" >mysql_list_fields()</B > retrieves information about the given table name. Arguments are the database name and the table name. A result pointer is returned which can be used with <A HREF="function.mysql-field-flags.html" ><B CLASS="function" >mysql_field_flags()</B ></A >, <A HREF="function.mysql-field-len.html" ><B CLASS="function" >mysql_field_len()</B ></A >, <A HREF="function.mysql-field-name.html" ><B CLASS="function" >mysql_field_name()</B ></A >, and <A HREF="function.mysql-field-type.html" ><B CLASS="function" >mysql_field_type()</B ></A >. </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN59190" ></A ><P ><B >Example 1. <B CLASS="function" >mysql_list_fields()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); $fields = mysql_list_fields("database1", "table1", $link); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { echo mysql_field_name($fields, $i) . "\n"; }</PRE ></TD ></TR ></TABLE ><P > The above example would produce the following output: <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >field1 field2 field3 ...</PRE ></TD ></TR ></TABLE > </P ></DIV ></TD ></TR ></TABLE > </P ><P > For downward compatibility <B CLASS="function" >mysql_listfields()</B > can also be used. This is deprecated however. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.mysql-list-dbs.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.mysql-list-processes.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >mysql_list_dbs</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.mysql.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >mysql_list_processes</TD ></TR ></TABLE ></DIV ></BODY ></HTML >