如何用php获取数据库信息并显示

如题所述

获取ppq数据库的所有表名的代码:
?php
$server='localhost';
$user='root';
$pass='12345';
$dbname='ppq';
$conn=mysql_connect($server,$user,$pass);
if(!$conn)
die("数据库系统连接失败!");
$result=mysql_list_tables($dbname);
if(!$result)
die("数据库连接失败!");
while($row=mysql_fetch_row($result))
{
echo
$row[0]."
";
}
mysql_free_result($result);
?
mysql_list_tables
(PHP
3,
PHP
4
,
PHP
5)
mysql_list_tables
--
列出
MySQL
数据库中的表
说明
resource
mysql_list_tables
(
string
database
[,
resource
link_identifier])
mysql_list_tables()
接受一个数据库名并返回和
mysql_query()
函数很相似的一个结果指针。用
mysql_fetch_array()或者用mysql_fetch_row()来获得一个数组,数组的第0列就是数组名,当获取不到时
mysql_fetch_array()或者用mysql_fetch_row()返回
FALSE。
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答
大家正在搜