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 Tony on 10/06/84 11:17

"Aaron Reimann" <aaron.reimann@gmail.com> wrote in message
news:1117551335.836152.149610@o13g2000cwo.googlegroups.com...
>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.
>
> Here is human code:
> print a <tr>
> if only 1, 2 or 3 results have been returned, show the results and
> print a </tr>
> if 4, 5, and or 6 results have been returned, print <tr> and show
> results
> if no more results have been returned, print </tr>
>
> Does that make sense? Can anyone help?


Try something like this:

echo "<tr>";
for ($i = 0; $i < pg_numrows($r); $i++) {
echo "<td>";
// output your info here
echo "</td>";
if ( ( $i + 1 ) % 3 == 0 ) { echo "</tr><tr>"; }
}
echo "</tr>";

 

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

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