如何在PHP脚本上显示MySQL数据库? [英] How to show MySQL databases on a PHP script?

查看:77
本文介绍了如何在PHP脚本上显示MySQL数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行此操作时,我想显示服务器上所有数据库的列表:

I want to display a list of all the databases on my server, when I do this:

echo mysql_query(" SHOW DATABASES ");

我收到此错误:

Resource id #3

那怎么办呢?

推荐答案

您需要从查询中检索结果集,如下所示:

You need to retrieve a result set from the query, like so:

$set = mysql_query('SHOW DATABASES;');
$dbs = array();
while($db = mysql_fetch_row($set))
   $dbs[] = $db[0];
echo implode('<br/>', $dbs);

这篇关于如何在PHP脚本上显示MySQL数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆