Replacing two bath fixtures on one switch
It sounds like you're not sure how this was wired up before, since the wire nuts came off when you pulled the fixture off.

There are a couple of different things that could be going on here.

You either have:


Power coming into the switch box, then going to the lights, with the switch cutting the hot wire to the lights (this is what I believe you have).
Power coming into one of the ceiling boxes with a "switch leg" running from one of the ceiling boxes to the switch box on the wall.


It looks to me as if you have power in the switch box, wired straight through the pictured ceiling box to the other ceiling box. Does the other ceiling box only 1 black, 1 white and 1 bare grounding wire in it?

If I'm right about the power coming into the switch box, then you want to:


Connect the black wire from your fixture to both black wires in the ceiling box.
Connect the white wire from your fixture to both white wires in the ceiling box.
Connect the ground wire from your fixture to both grounding wires in the ceiling box (there must be another one up inside the box, or they're pig-tailed into one wire) and connect the ground to the metal strap on that box, as well (the green ground screw). The metal parts on your fixture will be grounded when you screw the fixture to that metal strap to attach it to the ceiling.