Location: PHPKode > projects > AJAX MySQL Admin > ajaxmysqladmin/www/api/databases.php
<?php
    require_once ('inc/constants.inc');
    require_once ('inc/generic_start.inc');
    $shown = false;

    if (isset($_GET["set"])) {
        $dbname = $_GET["set"];
        $query = "UPDATE connections SET dbname='" . $dbname . "' WHERE username='" . $username . "'";
        mysql_query ($query, $app_conn);
        echo "{response:1}";
    } else {
        if ($dbhost != null) {
            ?>
            {
            page: 1,
            total: 1,
            rows: [
                <?php
                $conn = mysql_connect ($dbhost . ":" . $dbport, $dbuser, $dbpass);
                $result = mysql_list_dbs ($conn);
                if ($result !== FALSE && mysql_num_rows ($result) > 0) {
                    $count = 1;
                    while( $row = mysql_fetch_object ($result)):
                        if ($count > 1) echo "," . NL;
                        echo "{id:'" . $count . "', cell:['" . $count . "','" . $row -> Database . "'], selected:" . ($row -> Database == $dbname ? "'selected'" : "''") . "}";
                        $count ++;
                    endwhile;
                    mysql_free_result ($result);
                }
                mysql_close ($conn);
                ?>
                ]
            }
            <?php
            $shown = true;
        }

        if (!$shown) {
            echo "{page:1,total:0}";
        }
    }

    require_once ('inc/generic_finish.inc');
?>
Return current item: AJAX MySQL Admin