cell iterations in loop

From: Date: Thu, 26 Apr 2001 18:32:13 +0000
Subject: cell iterations in loop
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-50484@lists.php.net to get a copy of this message
I've got some code that I am creating that creates a table with a loop. and it works fine for what it is, but my question is how do I compensate for rows that aren't divisible by 5 ? i.e. the empty cells at the table. additionally if it ends on a complete row (divisible by 5) I end up with an additional empty row at the end of the table, I can see why it does, I'm just trying to get around it. no big hurry on this, I'm just trying to learn more. <snip> <table width="450" border="1" align="center"> <tr> <? $x = 0; while ($x <= 42) { $x++; if ($x % 5 == 0) { echo "<td>".$x."</td>\n"; echo "</tr>\n<tr>\n"; } else { echo "<td>".$x."</td>\n"; } } ?> </tr> </table> </snip> Jerry Lake - jerryl@europa.com Interface Engineering Technician Europa Communications - http://www.europa.com Pacifier Online - http://www.pacifier.com

« previous php.general (#50484) next »