簡體   English   中英

我在 php 中執行此代碼時選擇任何數據庫它只顯示表的數量而不是所選數據庫的所有表的名稱

[英]I am doing this code in php while selecting any database it only display the number of tables not the names of all tables of the selected database

<?php
    session_start();`enter code here`
    include 'dbconnect.php';

    $q=$_GET['q'];

    echo $field= "Tables_in_".$q;

    $sql = "SHOW TABLES FROM $q";

    $result= mysqli_query($conn,$sql);

     $new= array();
     $i=0;

    while ($row=mysqli_fetch_row($result)){
        echo $row['Tables_in_mysql'];

        $new[$i]=$row;
        $i++;
    }
    echo $num=count($new);
?>

<?php
    for($j=0;$j<$num;$j++){
        echo "here"; 
?>   

<?php echo $new[$j]['mysql']; ?>

<?php } ?>
<?php echo $q;?>

<?php
    session_start();`enter code here`
    include 'dbconnect.php';

    $q=$_GET['q'];

    echo $field= "Tables_in_".$q;

    $sql = "SHOW TABLES FROM $q";

    $result= mysqli_query($conn,$sql);

     $new= array();
     $i=0;

     while ($row=mysqli_fetch_row($result)){

        echo $row['Tables_in_mysql'];

        $new[$i]=$row;
        $i++;

    }
    echo $num=count($new);

?>

<?php for($j=0;$j<$num;$j++){      

    echo "here"; 
?>   


<?php echo $new[$j]['mysql'];   ?>

<?php } ?>
<?php echo $q;?>

這是我的代碼,請幫助我在 php 中打印所選數據庫表的所有名稱其中表的數量,但我想顯示表的名稱

由於您沒有發布任何代碼,因此這個答案可能不是您所追求的……但這將顯示當前數據庫中的所有表。

select `table_name` as 'table' 
    from `information_schema`.`tables` 
    where `table_type`='base table' and `table_schema`=database();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM