You will of course have to implement a paging mechanism if your results exceed rows*columns and you will need to get all of the items into a single array before you generate the <tr> and <td> elements. The following example code shows how you can generate the table you want
<?php
$data = array("a","b","c","d","e","f","g","h","i","j");
$rows = 4;
$itemCount=count($data);
echo "<table>";
for ($row=0; $row < $rows; $row++){
echo "<tr>";
for ($itemIndex=$row; $itemIndex < $itemCount; $itemIndex+=$rows){
echo "<td>".$data[$itemIndex]."</td>";
}
}
echo "</table>";
?>
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Offline 6,761 posts
since May 2007