<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
$db_list = mysql_list_dbs($link);
while ($row = mysql_fetch_object($db_list)) {
     echo $row->Database . "\n";
}
?>
     
    The above example will output 
something similar to:
 
    
database1
database2
database3