I'm not sure for certain (as I've never tried this) but you just need 2 connection strings, one for each server where you need to connect to data.
If I'm guessing correctly, the username part of the connection string would be user@IPaddress
Then when doing your queries,, assuming you've set one connection string up as $db1 and the other as $db2 you then simply drop the connection variable at the end of the relevant query:
$local_query = mysql_query("$sql", $db1);
$remote_query = mysql_query("$sql", $db2);
But its all guess work and I've no means of testing.