ooohh, sorry to tell you but your hamster most likely has wet tail, a very fatal sickness in hamsters.
if there's anyway you can get fluid in him/her (try filling a small syringe with water and get the hamster to drink it by slowly dropping the water in its mouth) this could be a way to save him/her.
the sickness makes them get diarrhea, which leads them to dehydration and then death. therefore the only way to help the hamster survive through the sickness is to keep them as hydrated as possible.
this mean administering water through a syringe directly into their mouth every half hour or every hour.