Its not possible, the only way its possible on PHP would be when your using clusters / several nodes with a replication setup.
Obviously you don't understand some of the more technical stuff in regards to mysql, but give this ago.
$master = mysql_connect("master_host","abc","abcdb");
$slave = mysql_connect("slave_host","xyz","xyzdb");
if(mysql_select_db("abc_db",$master) && mysql_select_db("xyz_db",$slave))
{
//Both Selected
$sql = mysql_query("SELECT * FROM employee",$master);
$rows = array();
while($row = mysql_fetch_assoc($sql))
{
//Query the other $slave DB here!
$slave_sql = mysql_query("SELECT * FROM department WHERE department_id = " . $row['id'],$slave);
while($sub_row = mysql_fetch_assoc($slave_sql))
{
$row = array_combine($sub_row,$row);
}
$rows[] = $row;
}
}
But thats not what you want to be doing really.
Just incase your trying to join across 2 databases on the same server, as both your hosts in your code are locahost, this is possible
SELECT * FROM db1.employees db1_e,db2.records db2_r WHERE db1_e.employee_id = db2_r.record_eid
But not sever 1 to an external server without using replication, even then you can replication wont be much help.
References and links:
http://nathan.rambeck.org/blog/2-joining-mysql-tables-across-multiple-databases
http://dev.mysql.com/doc/refman/5.0/en/replication.html