Row and column increment issue

I am trying to iterate through a series of data and put it into columns. Once 5 columns have data I want to increment the row.

What I have at the moment it sort of works until I get to 6 items and then fails with the row count reverting back to its previous value. I am sure that this is dead easy to do but I have been racking my brains without success. Any pointers most welcome.

This is what I have:
[php]
$col++;
if ($col < 6){$row = 2;}
else if ($col >5 && $col <11){
$row =3; $col =1;
}
[/php]

If you have an amount of data, it is simpler to get that data into an array, it if isn’t already, then use array_chunk() to break the data into the size chunks you want, then loop over the resulting array of rows of data. This will eliminate the need to use counters.

Where is this “series of data” coming from?

Sponsor our Newsletter | Privacy Policy | Terms of Service