Note that there are some explanatory texts on larger screens.

plurals
  1. POBuild Every 4 columns a row
    primarykey
    data
    text
    <p>How can I make every 4 columns it's own row in a table? Please don't tell me I should do them as div's, this needs to be a table...</p> <p>Here's my code:</p> <pre><code> $tmpRet = array_filter($ret, function($e){ return ($e['categoryID'] == 6) ? $e : null; }); $tmpRet = array_values($tmpRet); $tmpCt = count($tmpRet); $counter = 0; echo '&lt;table width="100%" cellpadding="10" cellspacing="5"&gt;' . PHP_EOL; for($i = 0; $i &lt; $tmpCt; ++$i){ $counter ++; echo ($i == 0 || $i % 4 === 0) ? ' &lt;tr&gt;' . PHP_EOL : null; 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 ($i == 0 || $i % 4 === 0) ? ' &lt;/tr&gt;' . PHP_EOL : null; } echo '&lt;/table&gt;'; </code></pre> <p>And It's spitting out:</p> <pre><code>&lt;table width="100%" cellpadding="10" cellspacing="5"&gt; &lt;tr&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="http://www.adp.com/" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/ADP_logo_tag_R_rgb 4-11-13.jpg" alt="ADP" title="ADP" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="http://ascensus.com/RetirementPlanSolutions/index.htm" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/Ascensus - color.jpg" alt="Ascensus" title="Ascensus" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="http://www.getbridgepoint.com/" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/Bridgepoint 2012.JPG" alt="Bridgepoint" title="Bridgepoint" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="http://www.brightscope.com/" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/BrightScope_Logo JPEG 10-10-12 approved.jpg" alt="BrightScope" title="BrightScope" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;tr&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="http://www.corporateinsight.com/" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/Corporate Insight Logo JPEG 9-26-12.JPG" alt="Corporate Insight" title="Corporate Insight" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="http://www.guardianlife.com/" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/Guardian Logo from 2011 OK.JPG" alt="Guardian" title="Guardian" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="http://www.infosysbpo.com" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/Infosys McCamish_natural_vert_nt jpeg.JPG" alt="Infosys McCamish" title="Infosys McCamish" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="http://ing.us/" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/INGC300.JPG" alt="ING" title="ING" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;tr&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="https://www.janus.com/" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/JANUS logoJPEG created 9-20-12.jpg" alt="Janus Capital Group" title="Janus Capital Group" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="http://www.jpmorgan.com/pages/jpmorgan" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/JP Morgan Logo for infotree.JPG" alt="JP Morgan" title="JP Morgan" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="http://www.newkirk.com/" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/Newkirk a DST Co 4-23-13.JPG" alt="Newkirk" title="Newkirk" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="http://www.oculuspartners.com/" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/Oculus_logo_v4-vert.jpg" alt="Oculus" title="Oculus" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;tr&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="http://us.pioneerinvestments.com" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/Pioneer Investments Jpeg ogo.JPG" alt="Pioneer Investments" title="Pioneer Investments" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="http://www.processunity.com/" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/ProcessUnity logo JPEG created 9-20-12.jpg" alt="ProcessUnity" title="ProcessUnity" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="http://www.prudential.com/view/page/public" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/Prudential Blue Gray for Lanyards.JPG" alt="Prudential" title="Prudential" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="http://www.rrdonnelley.com" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/RR Donnelley Logo for Mints.JPG" alt="RR Donnelley" title="RR Donnelley" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;tr&gt; &lt;td width="25%" align="center" valign="middle"&gt;&lt;a href="http://fc.standardandpoors.com/sites/client/us/crpsite/" target="_blank"&gt;&lt;img border="0" src="http://sparkusa.org/spark-forum/images/sponsors/sp_capitaliq_fc_logo.jpg" alt="S&amp;P Capital IQ" title="S&amp;P Capital IQ" style="max-height:85px;" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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