Hi,

In last program, we have created a database “trainee”. Now we are going to see a created database by using given PHP program. You know very well how to connect and create new database, here we have used mysql_fetch_assoc(); to stores all databases in an associative array. The stored databases was selected by using while loop.

Lets move into the program,

<?php
/* View All Databases */
$host = “localhost”;
$user = “root”;
$pass = “”;
$connect=mysql_connect($host, $user, $pass);
$query=”show databases”;
$mysql=mysql_query($query);
$row=mysql_fetch_assoc($mysql); // stores all databases as an associative array
while($row=mysql_fetch_assoc($mysql))
{
echo $row[‘Database’].”<br>”;
}

?>

OUTPUT:

// The stored databases are

information_schema
mysql
payilagam
performance_schema
phpmyadmin
student
test
trainee // This is your last created database trainee