Simple Uses for Loop
This is an image I use as a link. If the width of the star is 20, let's put ten of them across to make a line of 200 pixels. Here's the code for it: <? $times = 10; $x = 0; while ($x < $times) { echo "<img src=/artcode/star.gif height= 20 width=20 alt=star border=0 />"; ++$x; } ?> You can loop html also as in this example. No quote marks are used inside the html. Here's the code for it: <tr> <? $times = 10; $z = 0; while ($z < $times) { echo "<td bgcolor=red width=10 height=10></td> <td bgcolor=blue width=10 height=10></td>"; ++$z; } ?> </tr></table> You can loop both as in this example. Here's the code for it: <tr> <? $times = 10; $Q = 0; while ($Q < $times) { echo "<td><img src=/artcode/star.gif height= 20 width=20 alt=star border=0 /></td> <td bgcolor=blue width=20 height=20></td>"; ++$Q; } ?> </tr></table> |