mysql_tablename
(PHP 4, PHP 5)
mysql_tablename — 取得表名
警告
   
 本擴充套件自 PHP 5.5.0 起已廢棄,並在自 PHP 7.0.0 開始被移除。應使用 MySQLi 或 PDO_MySQL 擴充套件來替換之。參見 MySQL:選擇 API 指南來獲取更多資訊。用以替代本函式的有:
- SQL Query: SHOW TABLES
說明
   mysql_tablename(resource 
  $result, int $i): string|false
   從 result 中取得表名。
  
   此函式已廢棄,推薦使用
   mysql_query() 函式來執行 SQL SHOW TABLES
   [FROM db_name] [LIKE 'pattern'] 替代。
  
返回值
   成功時返回表名 或者在失敗時返回 false。
  
Use the mysql_tablename() function to traverse this result pointer, or any function for result tables, such as mysql_fetch_array().
更新日誌
| 版本 | 說明 | 
|---|---|
| 5.5.0 | mysql_tablename() 函式已廢棄,呼叫時會拋出 E_DEPRECATED級別的錯誤。 | 
範例
示例 #1 mysql_tablename() example
<?php
mysql_connect("localhost", "mysql_user", "mysql_password");
$result = mysql_list_tables("mydb");
$num_rows = mysql_num_rows($result);
for ($i = 0; $i < $num_rows; $i++) {
    echo "Table: ", mysql_tablename($result, $i), "\n";
}
mysql_free_result($result);
?>
註釋
注意:
The mysql_num_rows() function may be used to determine the number of tables in the result pointer.
參見
- mysql_list_tables() - 列出 MySQL 數據庫中的表
- mysql_field_table() - 取得指定欄位所在的表名
- mysql_db_name() - 取得 mysql_list_dbs 返回的結果數據