Re: splitting list into columns [message #183406 is a reply to message #183405] |
Tue, 22 October 2013 23:31 |
Christoph Michael Bec
Messages: 207 Registered: June 2013
Karma:
|
Senior Member |
|
|
richard wrote:
> I want to display the 200 item list into 5 columns.
> What I have now works, except that the 2 to 5th columns are not adding
> properly.
> What do I need to change to make it work right?
To create a table from a 1-dimensional indexed array $values in N-order,
you may use the following outline:
$rows = 40;
$cols = 5;
echo '<table>';
for ($i = 0; $i < $rows; ++$i) {
echo '<tr>';
for ($j = 0; $j < $cols; ++$j) {
echo '<td>';
$n = $j * $rows + $i;
echo $values[$n];
echo '</td>';
}
echo '</tr>';
}
echo '</table>';
--
Christoph M. Becker
|
|
|