3 colums....

From: Date: Thu, 02 Jan 2003 18:14:50 +0000
Subject: 3 colums....
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-129968@lists.php.net to get a copy of this message
I need some sleep right now, my brain is in low gear.... Here's what I'm trying to do. Basically have 3 HTML columns (<td></td>) printed to a web page but have them in alphabetical order from top to bottom and then continuing onto the next column. Like you would see in an index of a book. This code works fine except for when there are 4 items (dbrows) to be displayed. ceil($rows / 3) (see below) becomes 2 so it allows two items in each colum resulting to only 2 HTML colums being displayed. Can anyone come up with a better way to do this? ---------------- Start ------------------------------------------------------------------- <?php for ($j=1; $j<20; $j++){ $rows = $j; print "\n\n<!-- NEW TABLE -->\n\n"; print "<table border=\"1\"><tr><td valign=\"top\">\n\n"; print "<table>\n"; for ($i = 1; $i < $rows+1; $i++) { print "<tr>\n"; print "<td>Data</td>\n"; print "<td>$i</td>\n"; print "</tr>\n"; if ($i % ceil($rows / 3) == 0 ){ print "</table></td>\n"; if ($i != $rows ){ print "<td valign=\"top\"><table>\n"; } } } print "</tr></table>\n\n"; print "</td></tr></table>\n"; print "\n\n<!-- Close NEW TABLE -->\n\n"; print "<p>"; print "<HR>"; print "$j"; print "<HR>"; print "<p>"; } ?> --------------------------- End ---------------------------------------

« previous php.general (#129968) next »