$tr = 0; while($array = mysql_fetch_assoc($Ar)) { $tr++; echo 'text '; if($tr % 3 == 0) { echo '</tr><tr>'; } }