Ok, I am looking to use php to access two databases. The form posts into database 1 (person), while I have in the form two drop down menus that access a second database named (pulldown) to populate themselves. So it would look like this. Now I know to access one database you need to enter in $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) Code (markup): How does it work when you need to access two of them? Now the pull down code isn't an issue, but it is when it is inserted into a form like what I want, how I want to do it, it is. Can anyone here help? So what I want is to have access to person and pulldown at the same time, even though data is being pulled from pulldown and entered into person. Does this make any sense?
You will need to make another database connection. For example: To access Database 1 $db1 = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) $result1 = mysql_query("SELECT * FROM people", $db1); Code (markup): To access Database 2 $db2 = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) $result2 = mysql_query("SELECT * FROM info", $db2); Code (markup): It would be better if you had both tables in the same database, but I realize that's not possible always.
How will the Php code know where to pull the data from? The reason for not having them in the same database is simple, one will only have data entered to enter a new name, the other will have data entered, changed, removed, etc continuously, I don't want to have the two databases messed up... thanks for the help.
it's by the $db1 and $db2 variables.. if you want to pull data from database2 use $db2 in mysql_query.. don't forget to put it in the second parameter..