i have this problem for 3 days already 🙁
i created a 3 databases via phpmyadmin
and i already put those 3 database into a dropdown list
what i wanted is, when ever i click submit, the default database changes dependin on the value of the dropdown list
this is the code i came up to
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="form2" method="post" >
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td colspan="3"><center><strong>Select Default Database</strong></center></td>
</tr>
<tr>
<td><center><select name="db_used">
<?php
$host="localhost";
$username="root";
$password="";
$link = mysql_connect("$host", "$username", "$password")or die("cannot connect");
$result = mysql_list_dbs( $link );
while( $row = mysql_fetch_object( $result ) ){
echo "<option>$row->Database</option>";
}
?>
</select></center></td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<?php
$host="localhost";
$username="root";
$password="";
$db_name = "#this depends on the value of the dropdown list";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
?>
any help is greatly appreciated~~
Hoping this will help you.You can do it as:
create index.php
Crate generate.php
Create dbConnection.php