I wouldn't see that working: if there are no records the while() loop wouldn't run at all - and won't see the "No homework" bit inside.
I wouldn't use a while() loop anyway; I'd use an if() branch to decide if there was something to do, and only loop if I had something loop over.
mysql_query(...)
if(mysql_num_rows(...)<1)
{ No homework
}
else
{ while($row=...)
{ do a row.
}
}
I wouldn't even write it like that.
mysql_query(...)
$row_count = mysql_num_rows(...);
if($row_count==0)
{ No homework
}
else
{ for($i=0; $i<$row_count; $i++)
{ $row = ...
do a row.
}
}
Faster, and you know which row you're on.