You have a whole bunch of spaces (9 to be exact) after the EOT;
in the loop.
From the manual
… there may not be any spaces or tabs before or after the semicolon …
Why are you wrapping the $output
variable inside a HEREDOC string? I’d just change the loop to
printf('<tr><td align="left">%s</td><td align="left">%s</td></tr>',
htmlspecialchars($row["name"]),
htmlspecialchars($row["dr"]));
or even better, use PHP’s alternative syntax.