Hi, It sounds like he may have colitis, which is inflammation of the large intestine. It hurts to poo, and often they really need to go very frequently and desperately(fecal urgency). The pain is due to the inflammation. If he is still eating, then the best way to sort it is by putting him on a light diet for 2-3 days. The best thing is scrambled egg and boiled rice, small meals 2-3 times a day. This is low in fat, and as its usually fat that inflames the colon, this diet will help.
If it continues despite the light diet, see your vet, as it may mean something else is going on.
Hope this helps
regards Andrea
I am a practising veterinary surgeon in the UK. I will do my very best to help you online, but this cannot substitute being seen by your own vet.