TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 10-13-2009, 05:50 PM   #1 (permalink)
The Contributor
 
Join Date: Jan 2009
Posts: 40
Thanks: 10
Scottymeuk is on a distinguished road
Default 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);
                } 
Scottymeuk is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Status List codefreek TalkPHP Developer Team 12 11-24-2008 12:23 AM
You are subscribed to this thread mysql update with multi fields sarmenhb Advanced PHP Programming 0 11-15-2008 05:00 AM
how do you do a automatic status print on website like this codefreek General 2 10-25-2008 04:43 PM
Speeding up MySQL updates Dave MySQL & Databases 5 07-21-2008 04:39 PM
mysql -- most efficient way to batch process UPDATES drewbee Advanced PHP Programming 3 05-06-2008 12:09 PM


All times are GMT. The time now is 04:22 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design