Try something like this: $stories = $this->Story->findAll(array('complete' => 0), null, null, null, null, -1);
foreach ($stories as &$story) { $comments = $this->Story->Comment->findAll(array('story_id' => $story['Story']['id']), 'content', 'created_at DESC', $story['viewablecomments'], null, -1); $story += array('Comments' => $comments); } $this->set(compact('stories')); Now bear in mind I haven't tried this and I'm just typing code into a little textarea, so I've probably got it slightly wrong... but here's what it should do: First, fetch all the stories, as you were doing it. It's in a sensibly named array, on a fairly easy to read line that does nothing else. Then loop through every story. The &$story bit, with the ampersand, means that as it's looping, the code in the loop can alter the story rather than just passively view it. The loop itself builds up an array of comments related to just that story. I think your use of the array() function in this line is unnecessary, though it's too late in the night for me to work out if it'd cause a problem or not. :) Also, $story['story']['id'] should be $story['Story']['id'] as model names are always UpperCamelCase, but again, I'm not sure if that would cause a problem or not. What the loop then does is takes all these comments and appends them to the appropriate row of the original $stories array. (Again, it's late, so I may not have this quite right, but hopefully you should be able to see what I'm trying to do here.) This way, in your view's $stories foreach, you'll already be able to use $story['Comments'] as a handy list of comments just related to that particular story - which is probably easier than what's currently in your view, finding stories in the $comments array that have the right index. Although this is probably a bit neater, I'm still not entirely sure why your original code failed, but maybe this will have better luck? Let me know how it goes! It took me ages to wrap my head around arrays at first, so if you're new to PHP you're doing well already! Hope that helps, Zoe. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---