Re: Automatically generating 's?

Tue, 16 May 2006 08:20:39 -0700


roberts.sean wrote:
> I'm looking for a quick and elegant way to generate table elements with
> a set number of columns per row.  For example, if I have an array of 30
> images and I want to generate a table with three images per row.  The
> way I've done this before working with Cake involves multiple for()
> conditions and I'd rather not use it if I can get around it.  Does Cake
> have built in functionality for generating tables?
>
> Thanks!

How about something like this (untested and bare bones) code for your
3x10 example, in relavent view file, after popultating an array of
Image URLs in the controller:
..
<table>
<?php
$c = count ($FlatArrayOfImages);
for ($i = 0; $i < $c; $i + 3)
{
    $tr = Array (
        $html->image($FlatArrayOfImages[$i]),
        $html->image($FlatArrayOfImages[$i+1]),
        $html->image($FlatArrayOfImages[$i+2])
        );
    echo $html->tableCells($tr);
}
?>
</table>

There's probably some form of the above code that will cope with what
you are looking for.

Hope it helps, cheers,

AD7six


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to