PHP/MySQL Database/mysql tablename

Материал из Web эксперт
Перейти к: навигация, поиск

Listing databases

 
<?php
$conn = @mysql_connect( "localhost", "userName", "password" ) or die( "Sorry - could not connect to MySQL" );
$rs= @mysql_list_dbs( $conn ) or die( "Sorry - could not list databases" );
for( $row=0; $row < mysql_num_rows($rs); $row++ ){
  $db_list .= mysql_tablename( $rs, $row ) . "<br>";  
} 

?>
<html>
 <head>
  <title>Listing databases</title>
 </head>
 <body>
  <h3>
   <?php echo( $db_list ); ?>  
  </h3>
 </body>
</html>



mysql_tablename.php

 
<?php
   mysql_connect("localhost","webuser","secret");
   $tables = mysql_list_tables("company");
   $count = 0;
   while ($count < mysql_numrows($tables))
   {
      echo mysql_tablename($tables,$count)."<br />";
      $count++;
   }
?>