if you can 't connect to both DB at the same time, maybe the best thing to do is to connect on the first, retrieve the needed informations, close the connection, then connect to the second DB and retrieve the informations there as well
put all those thing in tables then do your output.