[eluser]srpurdy[/eluser]
There is no point in limiting the display to 4 per row. simply design your layout and css so 4 is all that can fit. If you force 4 per row you have some design issues later specially if you want a responsive design. Or need a mobile version. And don't use tables. They are slow.
I suggest taking a look at twitter bootstrap. Will give you a perfect example of what you want without using ugly tables. (FYI I'm not saying to never use tables) but for most things they are useless.)
And I suggest writing your code cleaner
use
Code:
<?php foreach():?>
html code <?php echo $row->field;?>
<?php endforeach;?>
and
Code:
<?php if():?>
html code <?php echo $row->field;?>
<?php endif;?>
This will make your code much more readable. you'll thank me later.