I've taken the liberty of adding bbcode tags to your original post to help with legibility (here's some information about [noparse]
...
[/noparse] and related tags[/url]); you may want to repair the indentation and other formatting.
As for your problem, I notice that you have two nested loops, the outer one fetching records into $r, the inner one fetching records into $row.
Since the outer loop fetches one record from the fourteen, that leaves thirteen for the inner loop, which goes through them all (to fill thirteen of the fourteen cells, using nothing to fill the fourteenth cell), and then both loops finish (the inner because it has run fourteen times and the outer because the result set is exhausted).
In short, that outer loop is redundant.