Okay, first of all I'm not clear on the exact intent of your question. Do you want to connect to two databases simultaneously? If so, here is what you need to do:
$link1 = mysql_connect($host1, $username1, $password1);
$link2 = mysql_connect($host2, $username2, $password2);
Then every time you invoke another mysql function, pass the link.
For example, if you want select database on $link1, do this:
mysql_select_db("database", $link1);
Every mysql function has an argument called "resource [link_identifier]". Refer to the manual to find out where this argument goes.
-sridhar