Re: Show data in two columns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux