This is awful for you to feel this way. Being ditched and/or abandoned is a terrible feeling.
Believe it or not, these bad experiences make you a stronger person. How? Because you've learned that you can only rely on yourself. If you're feeling down, make every effort to pull yourself up. It's not an easy task, but it can be done. As you've noticed, many people are only around for the good times.
This, my dear, means they were never your friend. Instead, focus on the person who matters most ... and that is you.