Use an order by of "type, name" as the third option in the findAll()

Then in your view you can do something like

$current = "";

foreach ($work in $works){
  if ($work['Work']['type'] != $current) {
    // print heading
  }
  // print name and other details
}

Geoff
--
http://lemoncake.wordpress.com

On Sep 1, 10:10 am, GunitMail <[EMAIL PROTECTED]> wrote:
> Hello!
>
> Ok here is how an entry in my database looks like:
>  [Work] => Array
>         (
>             [id] => 1
>             [name] => piece of work 1
>             [type] => Print
>             [date] => 2006-03-02
>             [description] => blah blah
>             [content] => <marquee>WORK!</marquee>
>         )
>
> How would I go about getting cakePHP to output these on a page like:
>
> <h2>Print</h2>
> + piece of work 1
> + piece of work 2
> + piece of work 4
> + piece of work 6
>
> <h2>Digital</h2>
> + piece of work 3
> + piece of work 5
>
> So they are grouped together with other entries that share the same
> value of a field.
> I'm not bothered about fancy db stuff, just some foreach and array
> action will make me happy.
>
> Thanks very much in advance, my PHP has become horribly rusty and dusty


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to