TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Status updates (http://www.talkphp.com/advanced-php-programming/5022-status-updates.html)

Scottymeuk 10-13-2009 05:50 PM

Status updates
 
Hey, I am using CakePHP to make a website. I have a bit of a problem. I am wanting to get status updates for each of my friends (Stored in a database table) but i only want to get 20 status updates maximum overall.

It's probably quite easy but I cannot work it out. Well I do have it done at the moment but its not as good as i want it.

What I have at the moment is:

PHP Code:

            $friends $this->Friends->Find('all', array('conditions'=>array('user_id'=>$this->Auth->user('id'), 'status'=>'1'), 'fields'=>array('user_friend')));            
            foreach (
$friends as $freind)
            {
                
$status[] = $this->Status->find('all', array('limit'=>5'conditions'=>array('author'=>$freind['Friends']['user_friend'])));
            }
            
            if (
$status)
            {
                foreach (
$status as $statuses)
                {
                    foreach (
$statuses as $statuses1)
                    {
                        
$statuses2[] = $statuses1;
                    }
                }
                
                
$statuses2 Set::sort($statuses2'{n}.Status.date''desc');
                
$statuses2 array_slice($statuses2020);
                
                if (
$statuses2)
                {
                    
$this->set('statusesData'$statuses2);
                } 


adamdecaf 10-14-2009 12:10 AM

This looks interesting.

PHP Code:

// Change
'limit'=>5

// To
'limit'=>20 



All times are GMT. The time now is 07:37 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0