Sicuro che il codice html generato sia corretto?

Magari ti sfugge qualche tag aperto e non chiuso...o viceversa (anche prima del while)