About food i am going to copy and paste for you from another thread
Flakes cause swim bladder issues more readily than most pellets. You should be using a high quality protein based pellet with the first two or three ingredients as whole fish not fishmeal or wheat. The flakes will also muck up his water quickly .The most recommended food New Life Spectrum by natural, Omega One betta pellets, i also using Aqueon they actually not the best one but i alternate them with others. You can buy spirulina brine shrimp and freeze dried blood worms by Hikari. I Hikari brand because it enriched with multi-vit.
But blood worms should be used only as a snack about 2 times a week because they can be cause of the bloating and constipation.
And also important how much you feed , make sure you not overfeed which also can lead to the swim bladder problem. Never follow the food box instructions , it completely wrong. How much you feed him?
Also be aware that bettas are very good jumpers so if you don't have the lid for your tank always leave the space between the water level and top of the tank, the same when you change him cover the net, or the cup you lure him in.