Tag : php

PDO code to show all databases

Showing a list of all the databases using PHP and PDO. <?php $user = ‘root’; $pass = ‘password’; $server = ‘localhost’; $dbh = new PDO( “mysql:host=$server”, $user, $pass ); $dbs = $dbh->query( ‘SHOW DATABASES’ ); while( ( $db = $dbs->fetchColumn( 0 ) ) !== false ) { echo $db.’ ‘; } ?> Will out a