龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

列出表 php列出数据库中的所有表

时间:2014-09-25 15:26来源:网络整理 作者:网络 点击:
分享到:
php列出数据库中的所有表 [代码片段(22行)]
<?php $conn = @mysql_connect( "localhost", "userName", "password" ) or die( "Sorry - could not connect to MySQL" );$rs1= mysql_list_dbs( $conn );for( $row=0; $row < mysql_num_rows( $rs1 ); $row++ )
{
  $this_db = mysql_tablename( $rs1, $row );
  $list .= "<b>".$this_db."</b><br />";
  if( $this_db != "mysql" )
  {
    $rs2 = mysql_list_tables( $this_db );

    for( $num=0; $num < mysql_num_rows( $rs2) ; $num++ )
    {
      $list .= " - " . mysql_tablename( $rs2, $num ) . "<br />";
    }
  }
}
?>

<html> <head>
  <title>Listing Tables</title>
 </head> <body>
  <?php  echo( $list ); ?>
 </body></html>

精彩图集

赞助商链接