You can connect to any number of databases with php in the same page instance - you just need to handle the links.
For example, you may have something similar to:
$db1 = mysql_connect(...);
To connect to db1 - Now, whenever you want to use db1 for anything (such as a query), you would use:
$result = mysql_query($query, $db1);
Thats sending a query using the connection of db1.
So obviously, create a $db2 link and reference it when you want to issue queries to that database.
Look at php.net/mysql_query and all other mysql_* functions, they all offer a 'link identifier' parameter, which is the $db1 variable you pass to them which you get returned from a mysql_connect call.