First of all, post the HTML you generate. Not the thing which is generating it. And second, get rid of the 90% of that code which doesn't have anything to do with your question. A reasonable example would be no more than 10 lines of code.
The only thing that kept the leeches off of me was this tiny ad: