Re: Fwd: GD library for creating tables
| From: | Osman Osman | Date: | Sat, 13 Dec 2008 13:56:51 +0000 |
| Subject: | Re: Fwd: GD library for creating tables | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-284584@lists.php.net to get a copy of this message | ||
Hey Tim,
Thanks for the reply. I'm actually looking for something to do that
exactly, but output it as an image (via GD, imageMagick, etc). I should've
been clearer; I mentioned it in the subject but not the actual e-mail.
There's actually a PEAR library that does that for HTML, HTML_Table:
http://pear.php.net/package/html_table/redirected.
I'm looking for
something very similar, which will allow me to output as an image.
On Sat, Dec 13, 2008 at 12:35 PM, Tim-Hinnerk Heuer <th.heuer@gmail.com>wrote:
> On Sat, 2008-12-13 at 10:18 +0200, Osman Osman wrote:
> > Hello,
> > I'm looking for a library in PHP that will let me easily create tables
> > programmatically. It would be great if I can just specify information
> about
> > the rows/columns, what each cell should contain, etc, and the table would
> > get created automatically. I should be able to do anything I would be
> able
> > to do with normal HTML tables. Is there anything like that available?
> >
> > Thanks,
> > Osman
>
> $arr = array(array('celldata row 1, col1', 'celldata row 1, col2'),
> array('celldata row 2, col1', 'celldata row 2, col2'));
>
> <table>
> <tr>
> <th>heading1</th>
> <th>heading2</th>
> </tr>
> <?php foreach ($arr as &$row): ?>
> <tr>
> <?php foreach ($row as &$col): ?>
> <td><?php echo $col ?></td>
> <?php endforeach ?>
> </td>
> <?php endforeach ?>
> </table>
>
> Do you really need a library for that? I had thought about this too but
> couln't come up with a good solution to do this generically and being as
> flexible as this. All you have to do is copy/paste the html code and put
> some php inbetween if you have a designed table with css and all that
> jazz.
>
> Tim
>
>