foreach($updates as $update):
foreach($update['Follow'] as $follow):
echo $follow['name'];
endforeach;
endforeach;
?>
To check the data layout, you could use <?php pr($updates); ?> or var_dump($updates);
On 27 February 2012 01:44, Ali Wasif <aliwasif2009@gmail.com> wrote:
Hey guys, I am having issues while using foreach...
This is what I have in my Updates Controller.... and its working fine.
While outputting the data in views/updates/index, I am using foreach
and I am not being echo out the users name from users table.
Can anyone help me with the foreach statement to echo out the users
name and other column values?
$options['joins'] = array(
array('table' => 'follows',
'alias' => 'Follow',
'type' => 'inner',
'conditions' => array('Update.user_id = Follow.followed_to')
),
array('table' => 'users',
'alias' => 'User',
'type' => 'inner',
'conditions' => array('Follow.followed_by = User.id')
));
$options['conditions'] = array('User.id='.$this->Session-
>read('Auth.User.id'));
$this->set('updates', $this->Update-
>find('all',array('Update.user_id='.$this->Session-
>read('Auth.User.id')), $options));
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
--
Kind Regards
Stephen
http://www.ninjacodermonkey.co.uk
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment