First of all, what nested while loop? Second of all, exactly what's wrong with it? And most of all, what the heck is this supposed to do? This code will only display the last result, if any, and $carriageReturn should definitely be out of the loop. Also, not a good idea to use ../ in any HREF's, as some browsers seem to hate it (don't remember which...)... and keep all HREF's in quotes:
<a href=\"../formCreatePage.php\">Test</a>
And if column pageName is a number, I would seriously question your column naming conventions, and strongly recommend using something like pageNumber. If it's a string and want to see if it's empty, something like this would work better:
if (!$pageName) {
So hopefully, that gives you more insight. Hope this helps 🙂