Hey guys. I did a search for this but can't seem to find the answer.
I am trying to create a table with dynamicaly that has 1 row and 4 collumns, but repeats and creates a new table if there are more than 4 items in the database.
FOr instance, if there were only 2 items in the database it would create this
<table width="100%" border="0" cellpadding="0">
<tr>
<td> </td>
<td> </td>
</tr>
</table>
If it has one item there would only be 1 <td>, if it had 4 items it would have 4 <td>'s. Maximum of 4 <td>'s.
If there are more than 4 items in the database it would create a new table and start over....etc, until the last items are reached.
I am trying to do this using the modulus function, but it is not working out exactly right. It is either starting or ending the <table> tags too soon.
Here is what I have so far, and thanks for any help.
<?php
$numRows=25;//Could be any unknown number
$counter=0;
for($i=0;$i<$numRows;$i++){
if($counter % 4 == 0){ ?>
<table width="100%" border="0" cellpadding="0" cellspacing="3" class="text"><tr>
<?php }//end if ?>
<td width="25%">Stuff Here></td>
<?php if($counter % 4 ==0){?>
</tr></table>
<?php }//end if
$counter++;
}//end for
?>