Apart from the fact that you haven't 'closed' the cell and row of the table in this printf statement (see below), there doesn't seem to be anything wrong.
// You have ...
printf("<tr><td><a href='%s?id=%s'>%s</a>",$PHP_SELF,$myrow["id"], $myrow["subject"]);
// Should be ...
printf("<tr><td><a href='%s?id=%s'>%s</a></td></tr>",$PHP_SELF,$myrow["id"], $myrow["subject"]);
If you've got this covered, the problem's not in this line.
What actually goes wrong?