search
Homephp教程php手册PHP4与MySQL数据库操作函数详解(六)

 

(8) 取数据库名和表名2个):
  
  1
mysql_list_dbs()
  
格式: int mysql_list_dbs(int link_identifier);
  
取得所有可用的数据库名(database name)
  
  
例子:
  
  php
  $connect = mysql_connect($host , $usr ,$pwd);
  $dbs = mysql_list_dbs($connect);
  $rows = mysql_num_rows($dbs);
  echo "database total : ".$rows;
  $i = 0;
  while($i  {
  $db_name[$i] = mysql_tablename($dbs , $i);
  echo $db_name[$i];
  $i++;
  }
  ?>
  
即可依次显示出MySQL中所有的数据库名字(database name )。
  Note :
相当于MySQL中的 show databases命令
  
  2
mysql_list_tables()
  
格式:int mysql_list_tables(string database name);
  
显示该数据库下所有的表的名字Table name
  
  
例子:
  
  php
  $connect = mysql_connect($host , $usr , $pwd);
  $tables = mysql_list_tables("mysql");
  $rows = mysql_num_rows($tables);
  echo "Table total : ".$rows;
  $i = 0;
  while($i  {
  $table_name[$i] = mysql_tablename($tables , $i);
  echo $table_name[$i];
  $i++;
  }
  
  ?>
  
  
即可依次显示出mysql下所有的表的名字
  Note :
相当于MySQL中的 show tables命令(先要用 use mysql命令选中1个数据库)
  
  
  

  
   
  



Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment