Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try it with nested <code>for</code> loops:</p> <pre><code>for($i = 0; $i &lt; $tmpCt; ++$i){ $counter ++; echo ' &lt;tr&gt;' . PHP_EOL; for($j = 0; $j &lt; 4 &amp;&amp; $i &lt; $tmpCt; ++$j, ++$i){ echo '&lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="' . $tmpRet[$i]['sponUrl'] . '" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/' . GetLogoPath($tmpRet[$i]['showType']) . '/images/sponsors/' . $tmpRet[$i]['sponFileName'] . '" alt="' . $tmpRet[$i]['sponName'] . '" title="' . $tmpRet[$i]['sponName'] . '" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt;' . PHP_EOL; } echo ' &lt;/tr&gt;' . PHP_EOL; } </code></pre> <p>One thing that might go wrong is that maybe PHP doesn't support <code>for</code> loops where two incrementations happen (haven't tested it), so if it doesn't, just put the <code>++$i</code> at the end of the inner <code>for</code> loop.</p> <p>This will go through 4 columns or until the last column is found. This way $j is a simple counter to 4, and $i is still the reference for the array. Now in pseudocode, it's</p> <pre><code>for(every column){ start row; for(4 iterations){ print or use the contents of a column; } end row; } </code></pre> <p><strong>EDIT</strong> As OrangePill suggested, this would also work</p> <pre><code>for($i = 0; $i &lt; $tmpCt; $i+=4){ $counter ++; echo ' &lt;tr&gt;' . PHP_EOL; for($j = 0; $j &lt; 4 &amp;&amp; $i+$j &lt; $tmpCt; ++$j){ echo '&lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="' . $tmpRet[$i+$j]['sponUrl'] . '" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/' . GetLogoPath($tmpRet[$i+$j]['showType']) . '/images/sponsors/' . $tmpRet[$i+$j]['sponFileName'] . '" alt="' . $tmpRet[$i+$j]['sponName'] . '" title="' . $tmpRet[$i+$j]['sponName'] . '" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt;' . PHP_EOL; } echo ' &lt;/tr&gt;' . PHP_EOL; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload