First off..don't panic. second thing to do..fast him a few days, he;s probably constipated. Then cook some green peas and shell them..see if he will eat them, or at least a bit of them. If not, try and find some daphnia, either frozen or freezed dried. I use that as my bettas turn their noses up at veggies. These are laxatives for fish.
Be sure and do partial water changes also. if his home is deep or he looks like he is having trouble getting to the top to breath, lower the water level if you can (If you have a filter, be sure lowering the level doesn't affect it)
After he recovers, feed only once a day, 2-3 pellets and then fast one day a week. if you also give bloodwroms, only do so once a week instead of pellets. I always pre-soak my bettas food. If feeding flaks, I would recommand changing over to betta pellets. Hikari makes a good pellet.
i hope this helps.
Here is a site to read a bit more about caring for bettas. Its by a breeder I buy from.
http://bettysplendens.com/articles/home.imp