WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World
List tables in a MySQL database

mysql_list_tables

(PHP 4, PHP 5)

mysql_list_tablesList tables in a MySQL database

Description

resource mysql_list_tables ( string $database [, resource $link_identifier ] )

Retrieves a list of table names from a MySQL database.

This function is deprecated. It is preferable to use mysql_query() to issue a SQL SHOW TABLES [FROM db_name] [LIKE 'pattern'] statement instead.

Parameters

database

The name of the database

link_identifier

The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If by chance no connection is found or established, an E_WARNING level error is generated.

Return Values

A result pointer resource on success, or FALSE on failure.

Use the mysql_tablename() function to traverse this result pointer, or any function for result tables, such as mysql_fetch_array().

Changelog

Version Description
4.3.7 This function became deprecated.

Examples

Example #1 mysql_list_tables() alternative example

<?php
$dbname 
'mysql_dbname';

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

$sql "SHOW TABLES FROM $dbname";
$result mysql_query($sql);

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

Notes

Note: For backward compatibility, the following deprecated alias may be used: mysql_listtables()

See Also


List all values in selected fields from selected tables from selected database
Categories : PHP, MySQL, Databases, HTML and PHP
Random lists from MySQL
Categories : MySQL
a function that builds an HTML select list from any mysql table.
Categories : PHP, MySQL, HTML and PHP



Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs.
Categories : Databases, PHP, MySQL, Complete Programs
Simple phone list search for your WAP device. Uses PHP and MySQL. Also lets you dial out to your entries using wtai://wp/mc if your phone supports it. No WMLscript.
Categories : PHP, MySQL, WAP
MySQL Optimizer - a class to analyze, optimize or repair tables of a MySQL database.
Categories : PHP, PHP Classes, MySQL, Databases
Locking tables in mysql.
Categories : MySQL, PHP, Databases
This PHP function creates dropdown select lists for time and date that you can change, outputs a 14 char MySQL timestamp in a text field
Categories : PHP, MySQL, Java Script, HTML and PHP
php,gratuit,email,mysql,mailinglist
Categories : PHP, MySQL
Online Automatic Class Generator for MySQL Tables
Categories : PHP, PHP Classes, Classes and Objects, Databases, MySQL
SQL Parsing Class - parse text files with a list of MySQL query statements to be executed.
Categories : PHP, PHP Classes, Databases, MySQL
PHP mySQL learning example This is a complete program to modify tables in a mySQL database on a nice and neat way.
Categories : PHP, MySQL, Complete Programs, HTML and PHP
Creating thumbnails from MySQL Blobs online
Categories : PHP, MySQL, Graphics, HTML and PHP, Databases
MySQL and substrings.
Categories : MySQL, Strings, Date Time, Databases