头像

php列出数据库中的所有表

2018-04-13 11:08:47 来源:PHP代码   浏览()   评论 ( 0 )   

<?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>


标签: phpmysql
声明:转载请注明来源(PHP代码)并保留原文链接:http://www.phpdaima.com//master-74.html
广告不存在
评论0

后面还有条评论,点击查看>>

温馨提示:为规范评论内容,垃圾评论一律封号...