cleaner code and prepare statements

I've prepared the sql statements and since I don't see any  data coming in from user input, that should be suffice. I cleaned up the way the code was written and fixed a link, so it works when you're previewing the site.