To prevent toenail fungus make sure you change your socks often, toenail fungus develops because of moisture and sweat being trapped. Also wash your feet often and clean your toenails.
To treat toenail fungus you can try some of these things.
There's a toe nail fungus cream that you can apply directly to the toenail.
There's also an anti fungus pill that you can get by prescription that is supposed to treat toenail and prevent toenail fungus.