在mysql教程 我們要顯示所有的表就會用到mysql_list_tables用法語法來操作,
mysql_list_tables 語法
ps教程is dc-description">resource mysql_list_tables ( string $database [, resource $link_identifier ] )
看個簡單的實例
<?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 tablesn";
echo 'MySQL Error: ' . mysql_error();
exit;
}while ($row = mysql_fetch_row($result)) {
echo "Table: {$row[0]}n";
}mysql_free_result($result);
?>
只是一個簡單的說明:
mysql的名單桌改變你的主動數據庫教程中。
例如:
<?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];
?>