Hi Michael,
Use a temporary variable [counter], if counter%3 == 0 then
write </tr><tr> in the output.
$counter=0; print "<tr>";
while($row = mysql_fetch_array($result)) {
echo "<td>".$row["user_id"]."</td>"; $counter++;
if (!$counter%3) { echo "</tr><tr>"; }
}
That's all ;-)
Ahmad Anvari
----- Original Message -----
From: Michael Hall
To: PHP List
Sent: Tuesday, February 06, 2001 10:03 AM
Subject: [PHP] Modulus Formatting
> I can pull data out of a database using mysql_fetch_array and assemble
it like this using a while statement:
>
> <TR><TD>$data</TD></TR>
> <TR><TD>$data</TD></TR>
> <TR><TD>$data</TD></TR>
> etc ...
>
> What I'd like to do is assemble it like this:
>
> <TR><TD>$data</TD><TD>$data</TD><TD>$data</TD></TR>
> etc...
>
> In other words, I need a break (</TR><TR>) every three times through the
> loop.
>
> I've tried several snippets of code from this list's archive but none seem
> to work. I've tried while statements, for statements and the list function
> in every combination I can think of ... no go. I know that modulus is
what I need but I can't crack the right code combination.
>
> Does anyone have a solution or can they point me to a resource somewhere?
>
>
> Thanks
>
> Mick
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]