That seems very strange indeed.
Does the query work ok if you run it by hand, say through phpmyadmin?
btw, you can change this:
if ($myrow = mysql_fetch_array($result)) {
do {
//--- record print stuff -----------//
} while ($myrow = mysql_fetch_array($result));
to this:
while ($myrow = mysql_fetch_array($result))
{
//--- record print stuff -----------//
}