You are here: Re: [PHP] Show data in two columns « PHP « IT news, forums, messages
Re: [PHP] Show data in two columns

Posted by Richard Lynch on 10/20/12 11:14

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация