I'm working on a photo album and I have a small problem with an if statement that use when I'm displaying the thumbs of my pics. There should be 4 pics in a row, like so: 1234 5678 Right now I'm only working on displaying the first row with the 4 pics My code works fine like this: [code]<?php $numcol = 1; ?> blah blah <div align="center"> <table border="0" width="648" cellpadding="5" cellspacing="2"> <tr> <?php while ($numcol < 5) { echo "<td width=\"162\" bgcolor=\"#e6e6e6\" valign=\"top\"><p align=\"center\">"; echo "<img border=\"0\" src=\"images/somepic.jpg\" width=\"150\" height=\"113\"><br>"; echo "<span class=\"text1\"><b>some text</b><br>some text<br>some text<br></span>"; echo "</p></td>"; $numcol++; } ?> </tr> </table> </div>[/code] However this code will only work properly if I have exactly 4 pics left to display. For this reason I added an if statement with an empty <td></td> to be poked in if there's no pic left to display to fill up my row with 4 td's Here's my code with the if statement that doesn't work: [code]<?php $numpicsleft=2; $numcol = 1; ?> blah blah <div align="center"> <table border="0" width="648" cellpadding="5" cellspacing="2"> <tr> <?php while ($numcol < 5) { if($numpicsleft > 1) { echo "<td width=\"162\" bgcolor=\"#e6e6e6\" valign=\"top\"><p align=\"center\">"; echo "<img border=\"0\" src=\"images/somepic.jpg\" width=\"150\" height=\"113\"><br>"; echo "<span class=\"text1\"><b>some text</b><br>some text<br>some text<br></span>"; echo "</p></td>"; $numcol++; $numpicsleft--; } else { echo "<td width=\"162\"></td>"; } } ?> </tr> </table> </div>[/code] Can anyone see why? It seems to be going into an eternal loop for some reason... Thanks.