gpt4 book ai didi

php - 如何在显示数据库 php mysql 中的表时读取表名

转载 作者:行者123 更新时间:2023-11-29 11:02:33 25 4
gpt4 key购买 nike

您好,我正在尝试从下拉列表中读取表名称,但无法提供名称选项名称。这是我的代码。

 <div class="form-group">
<label class="control-label col-sm-2" for="email">Enter number of titles:</label>
<div class="col-sm-10">
<select>
<?php
include 'config.php';
$query="show tables";
$result_query=mysqli_query($conn,$query);
while($row=mysqli_fetch_array($result_query))
{
echo "<option>$row[0]</option>";
}
?>
</select>
</div>
</div>

如何给出选项值或名称,因为有 10 个表,选择表后我需要读取表名称

谢谢

最佳答案

替换

echo "<option>$row[0]</option>";

echo "<option value='{$row[0]}'>{$row[0]}</option>";

关于php - 如何在显示数据库 php mysql 中的表时读取表名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41973415/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com