commented it, im unsure, I NEED HELP.

if anyone has more knowledge about php programming than me, please feel free to help me with my noobish, and hacky code, also, does htmlentities corrupt links when put into html?