Join Up!
96654 members and counting!

 
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links 
search for in the  
previousmysql_list_processesmysql_num_fieldsnext
Last updated: Tue, 28 May 2002
view the printer friendly version or the printer friendly version with notes or change language to Czech | German | Spanish

mysql_list_tables

(PHP 3, PHP 4 >= 4.0.0)

mysql_list_tables -- List tables in a MySQL database

Description

resource mysql_list_tables ( string database [, resource link_identifier])

mysql_list_tables() takes a database name and returns a result pointer much like the mysql_query() function. You can use the mysql_tablename() function to extract the actual table names from the result pointer, or any other result table function such as mysql_fetch_assoc().

The database parameter is the name of the database to retrieve the list of tables from. Upon failure, mysql_list_tables() returns FALSE.

For downward compatibility, the function alias named mysql_listtables() can be used. This is deprecated however and is not recommended.

Esimerkki 1. mysql_list_tables Example

<?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);
?>

See also: mysql_list_dbs(), and mysql_tablename().

User Contributed Notes
mysql_list_tables
add a note about notes
There are no user contributed notes for this page.
previousmysql_list_processesmysql_num_fieldsnext
Last updated: Tue, 28 May 2002
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by: http://phpbuilder.com/
Last updated: Thu Oct 31 18:34:28 2002 EST