prova così

codice:
...
echo "</tr>"; 
$riga=null;
while($riga=mysql_fetch_array($datiric)){
...