<HTML ><HEAD ><TITLE >mysql_list_tables</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_processes" HREF="function.mysql-list-processes.html"><LINK REL="NEXT" TITLE="mysql_num_fields" HREF="function.mysql-num-fields.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-processes.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-num-fields.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.mysql-list-tables" ></A >mysql_list_tables</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN59222" ></A ><P > (PHP 3, PHP 4 )</P >mysql_list_tables -- List tables in a MySQL database</DIV ><DIV CLASS="refsect1" ><A NAME="AEN59225" ></A ><H2 >Description</H2 >resource <B CLASS="methodname" >mysql_list_tables</B > ( string database [, resource link_identifier])<BR ></BR ><P > <B CLASS="function" >mysql_list_tables()</B > takes a database name and returns a result pointer much like the <A HREF="function.mysql-query.html" ><B CLASS="function" >mysql_query()</B ></A > function. You can use the <A HREF="function.mysql-tablename.html" ><B CLASS="function" >mysql_tablename()</B ></A > function to extract the actual table names from the result pointer, or any other result table function such as <A HREF="function.mysql-fetch-assoc.html" ><B CLASS="function" >mysql_fetch_assoc()</B ></A >. </P ><P > The <TT CLASS="parameter" ><I >database</I ></TT > parameter is the name of the database to retrieve the list of tables from. Upon failure, <B CLASS="function" >mysql_list_tables()</B > returns <TT CLASS="constant" ><B >FALSE</B ></TT >. </P ><P > For downward compatibility, the function alias named <B CLASS="function" >mysql_listtables()</B > can be used. This is deprecated however and is not recommended. </P ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN59247" ></A ><P ><B >Example 1. mysql_list_tables Example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php $dbname = 'mysql_dbname'; if (!mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) { print 'Could not connect to mysql'; exit; } $result = mysql_list_tables($dbname); if (!$result) { print "DB Error, could not list tables\n"; print 'MySQL Error: ' . mysql_error(); exit; } while ($row = mysql_fetch_row($result)) { print "Table: $row[0]\n"; } mysql_free_result($result); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ><P > See also: <A HREF="function.mysql-list-dbs.html" ><B CLASS="function" >mysql_list_dbs()</B ></A >, and <A HREF="function.mysql-tablename.html" ><B CLASS="function" >mysql_tablename()</B ></A >. </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-processes.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-num-fields.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >mysql_list_processes</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_num_fields</TD ></TR ></TABLE ></DIV ></BODY ></HTML >