It's inevitable; sooner or later your toilet will leak. Whether from a bad wax ring, bolts coming loose or a crack in the porcelain, all toilets leak from time to time. Hopefully you will notice before the water does any damage to the wood subfloor underneath. Replacing a wax ring or even the entire toilet is easier than replacing flooring. Most times the subfloor only needs a small area replaced, while the flooring itself will have to be totally replaced because you can't match it. But whatever the case, you must fix rotting wood before the toilet goes completely through the floor.
Remove the toilet. Turn water off to the toilet by closing the valve on the water line behind it. Disconnect the flex water line to the toilet at the valve. Flush and plunge the water out of the toilet. Unscrew nuts from the bolts at the bottom of the toilet with pliers or a wrench. If you can't turn them, cut the bolts just below the nuts with a hacksaw. Lift the toilet off the remaining bolts and place on a tarp, upside down. Remove the flange from the drain. Inspect to see if you can reuse it or if you need a new one.
Cut away the rotten wood. Cut at least a few inches past the rotted wood with a reciprocating saw, up to the closest joists. Discard all rotted wood and clean the drain well.
Measure the open area and cut a new piece of 3/4 inch plywood to fit. (If your subfloor is not 3/4-inch plywood, use plywood the same size as your current subfloor).
Measure from all sides to the drain and mark to cut. Using a hole saw cut the appropriate size hole in the plywood to fit around the drain.
Nail the plywood to the floor joists. Make sure to make your nails flush with the wood.
Clean the flange well or use a new one and install over the drain and new wood. You may need to scrape the flange with a small putty knife and use a wire brush to get it clean and free of any corrosion or debris.
Install flooring. If you were able to take up tile, you can reinstall it. If you had vinyl, you will need to put new flooring throughout the bathroom.
Clean bottom of toilet by removing old wax ring and all debris. You can use a small putty knife to scrape it and then clean with steel wool. Set in a new wax ring and push down so it doesn't fall off when you turn the toilet over.
Set new bolts in the flange and apply the holders. Place toilet down over the new bolts and right onto the flange. Do not put the toilet down on the wax ring anywhere else or you will distort the ring. Place the nuts on the bolts and tighten. Do not overtighten these nuts or you will crack the porcelain.
Cut the bolts to 1/2 inch over the nut and install the covers that hide them. Screw the flex water line back onto the water line and turn on the valve. The bolts may need to be tightened again after weight is applied to the toilet a few times.