Yes, all you need to do is keep your $link_id's separate, and use them in all of your database functions. They are optional since the functions will use the most recently opened connection to do it's work if it's not supplied, but that's not what you want.
Just open 2 connections and use the $link_id and you will be fine.
MySQL example:
$db1 = mysql_connect("db1", "user1", "pass1");
$db2 = mysql_connect("db2", "user2", "pass2");
$query1 = mysql_query("SELECT FROM table", $db1);
$query2 = mysql_query("SELECT FROM table", $db2);
This is a simple example but that's all there is to it.