我正在尝试使用此代码在数据库中显示所有表格。
<label>
<select class="selectpicker" name="tabel">
<?php
include "koneksi.php";
$koneksi ->select_db('testskripsi');
$sql = mysqli_query($koneksi, "show tables") ;
while($table = $sql->fetch_array(MYSQLI_ASSOC)) {
echo '<option name="opsi" value = "' . $table['Tables'] . '">' . $table['Tables'] . '</option>';
}
?>
</select>
</label>
这是我的结果
我想我不知道如何填充这个数组来显示我的表格
' . $table['Tables'] . '
答案 0 :(得分:1)
请尝试使用Tables_in_testskripsi而不是Tables.here是您的正确代码。
<label>
<select class="selectpicker" name="tabel">
<?php
include "koneksi.php";
$koneksi ->select_db('testskripsi');
$sql = mysqli_query($koneksi, "show tables") ;
while($table = $sql->fetch_array(MYSQLI_ASSOC)) {
echo '<option name="opsi" value = "' . $table['Tables_in_testskripsi'] . '">' . $table['Tables_in_testskripsi'] . '</option>';
}
?>
</select>
</label>
让我知道它是否对你有帮助
答案 1 :(得分:0)
获取表名,
$tables=$this->db->query("
SELECT t.TABLE_NAME AS myTables
FROM INFORMATION_SCHEMA.TABLES AS t
WHERE t.TABLE_SCHEMA = 'database name'
AND t.TABLE_NAME LIKE '%a%'
")->result_array();
foreach($tables as $key => $val) {
echo $val['myTables']."<br>";// myTables is the alias used in query.
}