Looping a table vertically and horizinally help needed....

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Jay

Postby Jay » Tue Sep 03, 2002 11:23 am

The way I normally do it is pass everything into an array! Then I cycle through the array using a very special algorithmn, i'll give you the gist!

First start with an ID number, this is how far you've gotten through your array! Then decide how many columns you want! You'll have to fill in the gaps yourself, I'm not writing your code for you:
$x represents the ID number!

Code: Select all

print "<table>\n";
for ($i=0;$i<sizeof($theArray);$i+=$cols) {
print "<tr>\n";

for ($cell=0;$cell<$cols;$cell++) {
if ($item < sizeof($theArray) {

print "<td>".$theArray[$x++]."</td>\n";
$item++} else {
print "<td>&nbsp;</td>\n";
}
}
print "</tr>\n";
}
print "</table>\n";

That's more or less it! You can adjust it to suit your own requirements!


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 3 guests