the easiest way is using a counter to 4 and then do  reset to
so you get
 if counter = 4 then
    reset counter
    write new line
endif

% calculates the modulo between $i and 2 = Remainder of $i divided by 2



----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 15, 2001 10:17 PM
Subject: getting multiple columns per row from databse query


> I have a database that is names and addresses. I want to make a web page
> that will display those
> names and addresses in a table with 4 columns per row, as many rows as
necessary. The little
> if statement below works to make 2 columns, but when I change the number
to 3 or higher it no longer
> works properly - I get the 3 or more columns wrapped to look like multiple
rows. (there's on long line,
> hopefully it will wrap properly).
>
> <?
> (html and connection lines snipped)...
> $sql = "select * from brochures";
> $result = mysql_query($sql);
> while ($row = mysql_fetch_array($result))
> {
> printf("<td>%s<br>%s<br>%s<br>%s<br>%s<br>%s, %s %s</td>\n",
$row["Account"], $row["name"], $row["email"], $row["Address"],
$row["Address2"], $row
> ["City"], $row["State"], $row["Zip"]);
> if ($i % 2)
> {
> echo "</tr>\n<tr>\n";
> }
> $i++;
> }
> ?>
>
> --
> Chip W
>
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to