Pretty much it doesn't matter - as long as the derailleur is comparable in brand and general "shape". The derailleur doesn't really care how many gears you have! The two things that have to be the same as (or compatible with) your old one:
Cable pull ratio - each "click" of your shifter pulls the cable a certain amount, and the derailleur has to move by the correct amount per click. So - if it's a shimano, get a shimano, and you'll probably be OK.
Capacity - if your largest tooth cog in back is a 32-tooth, no way is a "short cage" derailleur going to handle it. On the other hand if your largest in back is 23 tooth, a "long cage" would work but would look VERY SILLY
So, with several caveats to boot - as long as it's the same brand (or compatible), and approximately the same physical dimensions, it should be fine; 7, 8, 9 speed really doesn't matter. Post a close-up photo of the broken derailleur where we can read the model numbers/etc. and see the thing, and we'll give you a link where you can buy a replacement from :)