<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.12 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
  <refentry id="function.mysql-list-tables">
   <refnamediv>
    <refname>mysql_list_tables</refname>
    <refpurpose>List tables in a MySQL database</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>resource</type><methodname>mysql_list_tables</methodname>
      <methodparam><type>string</type><parameter>database</parameter></methodparam>
      <methodparam choice="opt"><type>resource</type><parameter>
        link_identifier
       </parameter></methodparam>
     </methodsynopsis>
    <para>
     <function>mysql_list_tables</function> takes a database name and
     returns a result pointer much like the
     <function>mysql_query</function> function. 
     Use the <function>mysql_tablename</function> function to
     traverse this result pointer, or any function for result tables,
     such as <function>mysql_fetch_array</function>.
    </para>
    <para>
     The <parameter>database</parameter> parameter is the name of the 
     database to retrieve the list of tables from.  Upon failure, 
     <function>mysql_list_tables</function> returns &false;.
    </para>
    <para>
     For downward compatibility, the function alias named 
     <function>mysql_listtables</function> can be used. This is 
     deprecated however and is not recommended.
    </para>
    <note>
     <para>
      The function <function>mysql_list_tables</function> is deprecated. It
      is preferable to use <function>mysql_query</function> to issue a
      SQL <literal>SHOW TABLES [FROM db_name] [LIKE 'pattern']</literal> statement instead.
     </para>
    </note>
    <para>
     <example>
      <title><function>mysql_list_tables</function> example</title>
      <programlisting role="php">
<![CDATA[
<?php
$dbname = 'mysql_dbname';

if (!mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) {
    echo 'Could not connect to mysql';
    exit;
}

$result = mysql_list_tables($dbname);

if (!$result) {
    echo "DB Error, could not list tables\n";
    echo 'MySQL Error: ' . mysql_error();
    exit;
}

while ($row = mysql_fetch_row($result)) {
    echo "Table: $row[0]\n";
}

mysql_free_result($result);
?>
]]>
      </programlisting>
     </example>
    </para>
    <para>
     See also
     <function>mysql_list_dbs</function> and
     <function>mysql_tablename</function>.
    </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
-->