Hi,
I just want to say that Iv only been doing php for a few days now but i think i can give you a good answer.
You want a drop down menu which decides which database the next page connects to only using html and php?
Form page:
<form id="connect" name="connect" method="post" action="connect.php">
<select name="dbchoice" id="dbchoice">
<option value="db1">db1</option>
<option value="db2">db2</option>
<option value="db3">db3</option>
</select>
</form>
Action page:
<?php
$dbchoice = $_POST['$dbchoice'];
//the above line gets the value from the drop down box on the previous page
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("$dbchoice") or die(mysql_error());;
//above this text NOW where it sayd $dbchoice, the server is writting in the value from the drop down form from the previous page. this means that the database chosen is the one with the same name as what the user chose on the form.
?>
I hope that answered your question =]
ps. the only thing im not 100% sure about is the format of this bit:
mysql_select_db("$dbchoice")
So if it dosnt work that is the section that is most likely to be wrong. Maybe ask somebody else or try
mysql_select_db($dbchoice)
MaxMumford
Posting Whiz in Training
228 posts since Oct 2006
Reputation Points: 32
Solved Threads: 3