getting the list of all the databased and there table
Posted: Mon Mar 22, 2004 5:50 am
how can i get the list of all databases and tables on mysql server?
thanks in advance
peleg
thanks in advance
peleg
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Both the previously mentioned ways are/can be done in PHP...hehpelegk2 wrote:what?
i asked hhow to do it in php!
Code: Select all
<?php
$db = mysql_connect('localhost', 'root', 'password') or die(mysql_error());
$sql = 'SHOW DATABASES';
$res = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_assoc($res)){
echo '<b>'.$row['Database'].'</b><br />';
mysql_select_db($row['Database']) or die(mysql_error());
$sql = "SHOW TABLES";
$res2 = mysql_query($sql) or die(mysql_error());
while($row2 = mysql_fetch_assoc($res2)){
$tblname = 'Tables_in_'.$row['Database'];
echo ' '.$row2[$tblname].'<br />';
}
}
?>