Column display or dashboard display help

Hello,

I have a small script or a dashboard that im working on that displays the col title and a count below the title.
example:
Col1 Col2 col3 col4 col5
3 5 3 8 2
Col6 Col7 col8 col9 col10
3 5 3 8 2

As of now the script displays one below the next.
What I like to do is:
display the first 5 cols cross the screen. if the col number reaches 5 repeat the same if there are more records to display below existing display.


$col = 0;
echo '<table border="1">';
foreach($displayDevice as $key1=> $value)
{	if ($value > 0)
	{	if($col < 4)
		{	$col++;
			echo "<tr><td>" . $key1  . "</td></tr>"; 
			echo "<tr><td>" . $value . "</td></tr>";
		} else { $col = 0;}
	}
}
echo "</table>";

Any thoughts on this?

Thanks


$col = 0;
$titlerow = array();
$valuerow = array();
echo '<table border="1">';
foreach ($displayDevice as $key1=> $value) {    
  if ($value > 0) {   // add new values to the two rows  
    $col++;
    $titlerow[] = $key1; 
    $valuerow[] = $value;
    if ($col > 4) {    // when there are five columns then display the two rows
      echo "<tr><td>" . implode("</td><td>",  $titlerow) . "</td></tr>"; 
      echo "<tr><td>" . implode("</td><td>",  $valuerow) . "</td></tr>"; 
      // reset variables
      $col = 0;
      $titlerow = '';
      $valuerow = '';
    }
  }
}
if ($col > 0) {   // display the remaining values (if any)
  echo "<tr><td>" . implode("</td><td>",  $titlerow) . "</td></tr>"; 
  echo "<tr><td>" . implode("</td><td>",  $valuerow) . "</td></tr>"; 
}
echo "</table>";  

edit: actually, if you can have a number of values that isn’t a multiple of 5 (12 for example), then you’d want to add three empty td’s to the last rows.

Thanks Guido2004… it works …