mysql_field_table
Gets the table name where the specified field is located.
Function name: mysql_field_table()
Version requirements: PHP 4, PHP 5, PHP 7
Function description: The mysql_field_table() function is used to return the table name where the specified field is located.
Syntax: string mysql_field_table ( resource $result , int $field_offset )
parameter:
Return value: If successful, return the table name where the field is located, otherwise return FALSE.
Example:
<?php // 创建数据库连接$link = mysql_connect("localhost", "username", "password"); if (!$link) { die("连接数据库失败: " . mysql_error()); } // 选择数据库$db_selected = mysql_select_db("mydb", $link); if (!$db_selected) { die("选择数据库失败: " . mysql_error()); } // 执行查询$result = mysql_query("SELECT * FROM mytable", $link); if (!$result) { die("查询失败: " . mysql_error()); } // 获取第一个字段的表名$table = mysql_field_table($result, 0); if ($table) { echo "第一个字段所在的表名是: " . $table; } else { echo "获取表名失败"; } // 关闭数据库连接mysql_close($link); ?>
Notes: