How to dynamically create four columns per line in a single row with php?

I am trying to create a form where i could display 4columns per line in a single row. the total nber of columns is 8.

I have tried myself but got stucked.I have made display the 1st four tables, but got stuck for the remaining 4 on the next line This is my code.

[php]<?php
$maxCol = 8;
$minCol = 4;

echo ’

Select a size and enter its qty
’;
echo'<div style="padding:5px;">';

for ($j=1; $j < $minCol; $j++) { 
   echo' <select name="">
   <option value="">Select a size</option>
   <option value="1">XL</option>
   <option value="2">XXL</option>';
   echo'</select>';

   echo' <input type="text" size="5" >';

}

echo '</div>';

?>[/php]

How to get display the remaining 4columns on the next line in the same row?

Hi there

The for loop in your code will have only three iterations. Try the following code:

[php]<?php
$maxCol = 11;
$minCol = 4;

echo ’

Select a size and enter its qty
’;

echo’

’;

for ($j=1; $j < $maxCol+1; $j++) {
echo’
Select a size
XL
XXL’;
echo’’;

    echo' <input type="text" size="5" >';
    if ($j % $minCol == 0) echo '<br>'; // Output line break after we've displayed four

}

echo ‘

’;[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service