Hi All,
I'm trying to create rows of boxes that will have two columns inside them depending on a variable. Here is how far I've got:
$total_columns = 5;
As you can see, there is a total of 5 columns needed, which means 3 boxes in total since it limits to two columns per box:
$total_boxes = ceil(($total_columns/2)); //returns 3 (5 / 2, rounded up)
Now we know we need a total of three boxes. Proceed to make the loop for each box:
//loop divs
$x = $total_boxes; //total boxes for loop
$y = $total_columns; //total columns for loop
for ($i = 1; $i <= $x; $i++)
{
echo '<div>';
This is where I get lost... I can't figure out how to get the loop to know if two set one or two columns inside the div.
For example, column 1 & 2 goes to first box, 3 & 4 goes to second box, now the fifth and last one... should be the only one in the third box.
And I also need to be able to put a <div> in between columns for boxes with two columns like so <COLUMN><DIV><COLUMN> but only for boxes with two columns.
I know it's confusing but if anyone can help me, would be greatly appreciated.