0
我正在嘗試使用函數mysqli_fetch_field()
來獲取數據庫中每個表的名稱。但是,當我嘗試使用$fieldInfo->table
輸出表名稱時,我得到了重複項。我怎樣才能從每個表中只選擇1列,以便$fieldInfo->table
不是針對每個表的每列調用的?PHP/SQL - 如何獲取數據庫中表的名稱?
當前SQL:
$sql = "SELECT * from administrators, bookings, customers, rooms";
$results = mysqli_query($conn, $sql)
or die ('Problem with query' . mysqli_error($conn));
我的代碼來顯示在單選按鈕表名:
<?php
while ($fieldInfo = mysqli_fetch_field($results)) {
?>
<input type="radio" name="tableNames" value="<?php echo $fieldInfo->table; ?>"> <?php echo $fieldInfo->table ?> <br>
<?php } ?>
'資源mysql_list_tables(字符串$數據庫[,資源$ link_identifier = NULL])',[function.mysql一覽tables.php](http://php.net/manual/en /function.mysql-list-tables.php) –
@FrayneKonok'mysqli'和'mysql'之間有區別... – arkascha
'SELECT 1 from administrative,bookings,customers,rooms'? – arkascha