Mysql_list_tables: code for displaying all data tables in a database

Source: Internet
Author: User
Tags mysql tutorial

In mysql, The mysql_list_tables usage syntax is used to display all tables,

In the mysql tutorial, all tables will be displayed.Mysql_list_tables usage syntaxTo operate,

Mysql_list_tables syntax

Resource Mysql_list_tables(String $ Database[, Resource $ Link_identifier])

Look at a simple instance

<? Php tutorial
$ 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, cocould not list tablesn ";
Echo 'mysql Error: '. mysql_error ();
Exit;
}

While ($ row = mysql_fetch_row ($ result )){
Echo "Table: {$ row [0]} n ";
}

Mysql_free_result ($ result );
?>

 

It is just a simple description:

The mysql List table changes in your active database tutorial.

For example:

<? Php
// Set databse context to db1
Mysql_select_db ("db1 ");

// List database tables from db2
Mysql-list-tables ("db2 ");
?>

<?
 
Mysql_connect ("localhost", "login", "passwd") or
Die ("Cannot connect:". mysql_error ());

Mysql_select_db ("db_name ");
 
$ Res = mysql_query ("show table status like 'table _ name'") or die (mysql_error ());
 
$ Row_res = mysql_fetch_array ($ res );
Echo $ row_res [Auto_increment];
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.