私はすでに3日間この問題を抱えています:(私はphpmyadminを介して3つのデータベースを作成し、それらの3つのデータベースをドロップダウンリストに入れました。送信をクリックするたびに、デフォルトのデータベースはドロップダウンの値に応じて変更されますリスト
これは私が思いついたコードです
<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");
?>
どんな助けでも大歓迎です~~