Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Display all databases in dropdown menu.

$
0
0

Hello everyone.I was trying to display all the databases available on a server in a dropdown list.But I could not get it.Here is my code.

<html>
<head>
<title>
List Databases
</title>
</head>
<body>
<?php
$connection = mysqli_connect('localhost','root','123456789');
if(!$connection)die(mysqli_connect($connection));else echo "Step 1:<br/>Successfully connected to MySQLi server<br/><hr/>";
$query = mysqli_query($connection,"SHOW DATABASES");
echo "Step 2:<br/>The databases available on this server are :<br/>";
while(($result = mysqli_fetch_assoc($query)) != NULL)
{
	echo $result['Database']."<br/>";
}
echo "<hr/>";
echo "<form method = 'POST' action = 'list-db.php'>";
echo "<select name = 'db[]'>";
$a = 0;
while($result[$a]!= NULL)
{
	echo "<option>$result[$a]</option>";
	$a++;
}
 
?>

Please help.


Viewing all articles
Browse latest Browse all 13200

Trending Articles