[英]When selecting any database it only displays the number of tables not the names of all tables of the selected database
[英]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.