list of table and database in php mysql

<?php
$con 
mysql_connect('localhost' 'root' ,'');
mysql_select_db('demo' $con ); 

$sql "SHOW TABLES FROM demo";
$result mysql_query($sql);

 echo ' Total Table = ' mysql_num_rows($result);

// list of table in database 
while ($row mysql_fetch_row($result)) {
    echo 
"<br> {$row[0]}\n";
}

mysql_free_result($result);
?>

<?php
// list of database 

$dblist mysql_query("SHOW DATABASES");
echo 
'<br> Total Database :'mysql_num_rows($dblist) . '<br> ';
while (
$row mysql_fetch_assoc($dblist)) {
    echo 
$row['Database'] . "<br>";
}

Advertisements

2 thoughts on “list of table and database in php mysql

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s