There are generally two types of zippers: closed-end, and open-end.
Closed-end zippers: stay fastened on one end of this type of zipper, like on jeans, and bags.
Open-end zippers: both sides come completely apart on this type of zipper, like on sleeping bags and jackets.
If a zipper is beyond repair:
Replace it with a new one of the same length. You can buy a zipper in a matching color from your local fabric store. With a seam ripper, carefully remove the stitching holding the old zipper in place. As you work, notice how the old zipper was put in, and in what order the various lines of stitching were made. Some zippers may be put in with several lines of stitching. Remove the old zipper and pull out all loose thread ends. Following the directions on the zipper package, pin the new zipper into place, laying it face down onto the garments seam, and stitch it in the same way the old zipper was stitched. When using pins you have to be more precise and use caution. Use a a zipper foot on the sewing machine. A zipper foot is able to adjust so it is on the left or the right side of the sewing machine needle. You'll need to slide it to the side you need so there is no presser foot on the zipper teeth. Many zipper feet require you to loosen a screw to slide it from side to side. The biggest mistake you can make is not re-tightening that screw! You can make the final topstitching on the outside of the garment, by hand or by machine. For me, it's always better using the sewing machine!
Here's a couple of fabulously crafty websites:
RetroSewing
AND
Cut Out + Keep