getting the list of all the databased and there table
Moderator: General Moderators
- pelegk2
- Forum Regular
- Posts: 633
- Joined: Thu Nov 27, 2003 5:02 am
- Location: Israel - the best place to live in after heaven
- Contact:
getting the list of all the databased and there table
how can i get the list of all databases and tables on mysql server?
thanks in advance
peleg
thanks in advance
peleg
install an admin tool like phpMyAdmin
http://sourceforge.net/project/showfile ... _id=220762
http://sourceforge.net/project/showfile ... _id=220762
Can also do it like this.
Loads of different ways really 
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 />';
}
}
?>