Re: Show data in two columns

From: Date: Wed, 27 Apr 2005 04:43:32 +0000
Subject: Re: Show data in two columns
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-213988@lists.php.net to get a copy of this message
On Tue, April 26, 2005 3:11 am, Amir Mohammad Saied said: > i want to extract the data from my DB (it's an articles database) and > want to show them in 2 columns way, like zend.com's articles section, > could any one help me? Do you want them in column order or row order? (left-right or up-down) $row = 0; echo "<table>\n"; while (list(...) = mysql_fetch_row(...)){ if (($row % 2) == 0){ echo "<tr><td>...</td>"; } else{ echo "<td>...</td></tr>\n"; } $row++; } echo "</table>\n"; OR $row = 0; $num_rows = mysql_num_rows(...); $cutoff = ceil($num_rows/2); echo "<table><tr valign='top'><td>\n"; while (list(...) = mysql_fetch_row(...)){ echo "...<br />\n"; if ($row == $cutoff){ echo "</td><td>\n"; } } echo "</td></tr></table>\n"; -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#213988) next »