Welcome Guest, Not a member yet? Register   Sign In
Making tables
#2

[eluser]gtech[/eluser]
sure there is a nicer way but this view works

Code:
<?php
  $counter=0;
  $cols=3;
  $list = array('0','2','1','2','9','0','1','2','9','2','1','2','9','0');
?>
<table border=1>
  &lt;?php foreach($list as $val):?&gt;
    &lt;?php if($counter==$cols) {$counter=0;}?&gt;
    &lt;?php if($counter==0):?&gt;<tr>&lt;?php endif;?&gt;
    <td>&lt;?=$val?&gt;</td>
    &lt;?php if($counter==($cols-1)):?&gt;
      </tr>
    &lt;?php endif;?&gt;
    &lt;?php $counter ++;?&gt;
  &lt;?php endforeach?&gt;

  &lt;?php for ( $i = 0; $i <= (($cols-1)-$counter); $i ++):?&gt;
    <td>-</td>
  &lt;?php endfor?&gt;
  &lt;?php if($counter!=$cols):?&gt;
     </tr>
  &lt;?php endif;?&gt;
</table>


Messages In This Thread
Making tables - by El Forum - 06-15-2008, 04:09 PM
Making tables - by El Forum - 06-15-2008, 07:14 PM
Making tables - by El Forum - 06-15-2008, 08:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB