You are here: Re: How do I return 3 results and print </tr> « PHP Programming Language « IT news, forums, messages
Re: How do I return 3 results and print </tr>

Posted by Alvaro G Vicario on 10/06/70 11:17

*** Aaron Reimann wrote/escribió (31 May 2005 07:55:35 -0700):
> I am trying to build a table using results from a database query.
> Right now (code below), the code displays each result in a new <tr>. I
> am wanted to display 3 results in one <tr> </tr>, and then create a new
> <tr> with another 3, etc.

$position=0;

while( ... ){
if($position==0){
echo '<tr>';
}

echo '<td>' . $data . '</td>';

if($position==2){
echo '</tr>';
}

$position=($position+1) % 3;
}


We leave completing last line as an exercise for the reader ;-)

--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--

 

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

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