Re: Displaying Data from DB into a Table
| From: | Ignacio Vazquez-Abrams | Date: | Fri, 17 Nov 2000 21:01:23 +0000 |
| Subject: | Re: Displaying Data from DB into a Table | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-25960@lists.php.net to get a copy of this message | ||
On Fri, 17 Nov 2000, Phillip S. Baker wrote:
> Greetings Folks,
>
> I am interested in displaying the data pulled form a MySQL DB into a table.
>
> What I would like to see is data that is displayed into three columns
> across and X rows. So the data would be pulled and then what is the PHp
> code I would need to write to get it to look like.
>
> 1 2 3
> 4 5 6
> 7 8 9
> 10 11 12
> Etc...
>
> Thanks in advance.
>
> Phillip S. Baker
>
> phillip@wordsandimages.com
> Words & Images
> 1535 Seabright Avenue, Suite 100, Santa Cruz, CA 95062
> Direct Line (831) 420-2641 / Fax (831) 458-0808
>
Try this:
<tr>
<?php
$i=0;
while ($row=mysql_fetch_array($result))
{
?>
<td><?=...?></td>
<?php
if (!((++$i)%3))
{
?>
</tr>
<tr>
<?php
$i=0;
};
};
?>
</tr>
--
Ignacio Vazquez-Abrams <ignacio@openservices.net>