[英]Printing all tables in a database
<?php
$connessione = mysqli_connect("localhost","root","","my_db");
$query = mysqli_query($connessione,"SHOW TABLES");
$array=mysqli_fetch_array($query);
print_r($array,1);
?>
Printing all tables in my_db. 打印my_db中的所有表。
The code returns an empty page. 该代码返回一个空白页。
error_reporting(E_ALL);
我添加了error_reporting(E_ALL);
at the top of the page, but it doesn't return nothing; 在页面顶部,但不会返回任何内容; SHOW TABLES
using phpMyAdmin and it works as it should. 我使用phpMyAdmin运行查询SHOW TABLES
,它可以正常工作。 How can I fix my code? 如何修复我的代码?
Here's what you need to do: 这是您需要做的:
<?php
$connessione = mysqli_connect("localhost","root","","my_db");
$query = mysqli_query($connessione,"SHOW TABLES");
while($row = mysqli_fetch_array($query)){
print_r($row);
}
?>
See here for a description of what mysqli_fetch_array
actually does. 有关mysqli_fetch_array
实际作用的说明,请参见此处 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.