MySQL List Databases


/ Published in: PHP
Save to your folder(s)

Fetch a list of available databases.


Copy this code and paste it in your HTML
  1. if (!function_exists('mysql_list_databases')) {
  2.  
  3. function mysql_list_databases($resources = Array()) {
  4.  
  5. $list = Array();
  6.  
  7. for ($i = 0; $i < count($resources); $i++) {
  8.  
  9. $dbs = @mysql_list_dbs($resources[$i]);
  10.  
  11. while ($row = @mysql_fetch_object($dbs)) {
  12. if ($row->Database != 'information_schema') { $list[] = $row->Database; }
  13. }
  14.  
  15. }
  16.  
  17. return $list;
  18.  
  19. }
  20.  
  21. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.