Ver original<table> <tr> <?php //Creo que la mejor forma es la siguiente $registros = 40; $i = 1; //Yo lo haria con un for pero tu lo quieres con un while no hay problema while($i<=$registros) { echo "<td>$i</td>"; if($i%2==0) { echo '</tr><tr>'; } $i++; } ?> </tr></table>