Monday, June 14, 2010

List DB and Tables using PHP

$conn = mysql_connect("localhost", "root", "") or die("Could not connect: " . mysql_error());
    //List DB
    $result = mysql_list_dbs( $conn );
    while( $row = mysql_fetch_object( $result ) ):
         echo  $row->Database "<br />";
    endwhile;

   //List Tables
  $db_name  = "test";
  $tables = mysql_list_tables("$db_name");
   while (list($table) = mysql_fetch_row($tables)) {
    $treeNodes->add($table,$table,$table,true,false,"","");
   }

  or
 $tables_list = mysql_query("SHOW TABLES FROM $db_name");

No comments:

Post a Comment

 

Followers