|
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]
|