【发布时间】:2014-04-27 15:29:38
【问题描述】:
我正在尝试从 MySQL 数据库中检索所有表名并将它们链接到下拉列表。然后我想将这些表名存储在一个表中并预览它们。
这是我的代码...
<?php
$sql = "SHOW TABLES FROM $ip";
$result = mysql_query($sql);
?>
<form id="form1" name="form1" method="post" action="newloay.php">
<select name="select" id="select" required>
<?php
while($row = mysql_fetch_array($result)){
?>
<option> <?php print $row[0] ?> </option>
<?php
} ?>
}
</select>
【问题讨论】:
-
表格很大,但表格名称声称抱怨用户最近发现的物品照片
-
您可能只使用查询直接填充下拉列表,而不是将表名存储在另一个表中,除非您将这些名称与其他数据一起使用。即使这样,您仍然可以使用连接从 MySQL 的模式中获取每个表名。
-
来自 PHP.net,
mysql_*扩展名:This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. -
这里的答案将对此有所帮助。 stackoverflow.com/questions/5439165/….