How do I get the list of databases in PHP/MySQL?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chetanpicha
    New Member
    • May 2007
    • 2

    How do I get the list of databases in PHP/MySQL?

    Hey in one of my allplication i want to retrieve all databases(using mysql presents in wamp) name in my combo box which is used in one of my form .
    So pls help as soon as possible. I am using PHP and html only. I just want to retrieve names of databases present in wamp(phpmyadmin ) to combobox.
    If u find the solution pls contact me on ([removed --pbmods])
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    Originally posted by chetanpicha
    Hey in one of my allplication i want to retrieve all databases(using mysql presents in wamp) name in my combo box which is used in one of my form .
    So pls help as soon as possible. I am using PHP and html only. I just want to retrieve names of databases present in wamp(phpmyadmin ) to combobox.
    If u find the solution pls contact me on ( vpchetan@gmail. com)
    [PHP]<?php
    $con = mysql_connect(' localhost', 'root', 'dba');
    $db_list = mysql_list_dbs( $con);

    $i = 0;
    $counter = mysql_num_rows( $db_list);
    echo '<select name="dblist">' ;
    while ($i < $counter)
    {
    $NAME = mysql_db_name($ db_list, $i);
    echo '<option value="'.$NAME. '">'.$NAME.' </option>';
    $i++;

    }
    echo '</select>';
    ?> [/PHP]

    Comment

    • ak1dnar
      Recognized Expert Top Contributor
      • Jan 2007
      • 1584

      #3
      Please read the POSTING GUIDELINES next time.
      Welcome to TSDN.

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Changed thread title to better match contents.

        Comment

        Working...