PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old November 3rd, 2009, 10:30 AM
claudfs claudfs is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Nov 2009
Posts: 1 claudfs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 39 sec
Reputation Power: 0
noob - Php Counting, Sorting, Grouping

THIS IS MY PHP CODE:

Code:
$query = "SELECT post_id, actor_id, comments, likes FROM stream WHERE source_id = ".$user." LIMIT 500";
$result = mysql_query($query);
$count = count($result);
$total=$count;


 for ($i = 0; $i < $count; $i++)
 {

 $actor_id = $result[$i][actor_id];
$count_c  = $result[$i][comments][count];

if($count_c > 0){
    for ($a = 0; $a < $count_c; $a++){
          $comment_id = $result[$i][comments][comment_list][$a][fromid];

    }
}

 
$count_l  = $result[$i][likes][count];

if($count_l > 0){       
        for ($b = 0; $b < $count_l; $b++){
            $likes_id = $result[$i][likes][friends][$b];
       
   }       
}



THIS IS WHAT IT REUTRNS WHEN I RUN IT

Code:

656531711
1516783097
674185730
609066002
656531711
674185730
1088321881
585794601
551252676
574493836
609066002
674185730

656531711
656531711
674185730
656531711
704318752
609066002



674185730
656531711
674185730
532183012
696220476
674185730
656531711
532273835
626576675
626576675
642160876
609066002
696220476
656531711
1117985931
609066002
609066002
656531711
626900263
532273835
626576675
555457370
656531711
515868989
674185730
656531711
1117985931
670474941
866155561
656531711
656531711
674185730
674185730
704318752
656531711
625090469
609066002
656531711
630999466
585794601
823541561
630999466
656531711
656531711
1254722891
656531711
607086243
870955113
656531711
607086243
609066002
574493836
656531711
656531711
656531711
1254722891
607086243
1254722891
1254722891
609066002
1254722891
656531711
574493836
656531711
610776430
656531711
656531711
1254722891
656531711
630999466
674185730
1254722891
656531711
656531711
674500606
794502841
625090469
615311059
626576675
656531711
656531711
630999466
609066002
1083630614
609066002
674185730
656531711
630999466
625090469
656531711
656531711
656531711
607086243
630999466
625090469
727581485
656531711
696220476
674185730
674185730
609066002
656531711
609066002
656531711
656531711
656531711
794502841
626576675
656531711
607086243
656531711
1083630614
609066002
609066002
100000192788370
656531711
607086243
674185730
674185730
656531711
607086243
1798532390
1083630614
656531711
1117985931
577218458
609066002
656531711
870955113
656531711
656531711
656531711
1083630614
674185730
609066002
656531711
656531711
656531711
643885079
642160876
656531711
656531711
1254722891
577218458
551252676
607086243
1254722891
674185730
870955113
642160876
656531711
727581485
727581485



546980094
560048573
1254722891
1516783097



656531711
577218458
577218458
656531711
605612222
1254722891
656531711
656531711
674185730
674185730
674185730
699890727
656531711
674185730
656531711
656531711
674185730
674185730
532183012
1792634671
609066002
605612222
674185730
674185730
609066002
564306576
609066002

609066002
609066002
630999466
696220476
674185730
609066002
609066002
609066002
609066002
609066002
609066002
564306576
674185730
609066002
674185730
674185730
609066002
630999466
605612222
674185730
609066002
609066002
638315931
609066002
609066002
674185730
656531711
574493836
609066002
532273835
674185730
630999466
609066002
609066002
674185730
577218458
1166813003
562271102
609066002
794502841
1259829408
538357861
704318752
597991014
566073511
726971495
532183012
870955113
616550716
670472168
664636476
870740326
727581485
517942396
1083630614
598622230
1254722891
660941442
699890727
748556354
674500606
878905455
585794601
647590657
823541561
1144432391
555457370
661632754
663243579
617346399
642160876
642160876
561991971
674185730
1226041688
577290311
573374896
630863016
696220476
674185730
609066002
664944194
609066002
1083630614
574493836
801405141
617346399
574493836
674185730
870955113
823541561
664944194
574493836
674185730
537328196
609066002
609066002
574493836
1254722891
1254722891
704318752
674185730
574493836
574493836
674185730
574493836
574493836
586614836
1254722891
870955113
710801556
674185730
660941442
674185730
664944194
702018082
1254722891
674185730
674185730
870955113
656531711
609066002
609066002
866155561
609066002
724721156
1083630614
574493836
660941442
674185730
605612222
615311059
660941442
664944194
609066002
702018082
878905455
870955113
609066002
1169014029
1083630614
609066002
1643126177
609066002
870955113
870955113
617454387
682037670
1516783097
647590657
866155561
523797078
585794601
866155561
551252676
664636476
870955113
609066002
586614836
609066002
585794601
609066002
560048573
609066002
870955113
717511299
664944194
664944194
720251764
753679615
753679615
560048573
674185730
870955113
870955113
577290311
609066002
544352078
609066002
586614836
1144432391
878905455
870955113
577290311
586614836
866155561
592660813
592660813
866155561
536884770
1254722891
598622230
626900263
609066002
609066002
609066002
866155561
609066002
605612222
701683592
866155561
866155561
670769071
866155561
866155561
866155561
866155561
866155561
866155561
1371472943
866155561
866155561
608643692
608643692
605612222
626900263
605612222
674185730
562271102
605612222
682661576
682661576
609066002
609066002
598622230
866155561
674185730
608643692
605612222
654691620
1135160691
654691620
870955113
608643692
753679615
753679615
605612222
702018082
870955113
866155561
608643692
866155561
870955113
605612222
605612222
605612222



Now all these integers represent a USER ID and there around 400 and lots have duplicate entries some even 50.

Now i would like a function or some code to work out how many entries there are of each unique integer.

For example the number

1.)609066002 appears 61 Times
2.)674185730 appears 48 Times

And i can't do it traditionally using COUNT and GROUP BY in the sql column as this is for FACEBOOK and they do not support COUNT and GROUP BY in the FQL.

Thanks any help would be appreciated..

Reply With Quote
  #2  
Old November 5th, 2009, 04:10 AM
wilorichie wilorichie is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Brisbane
Posts: 324 wilorichie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 15 h 29 m 24 sec
Reputation Power: 3
While the data is being extracted from the database, use some code like this:

Code:
if(isset($array[$userid])){

	$array[$userid] = $array[$userid] + 1;

} else {

	$array[$userid] = 1;

}


Just outside of the while loop, type

Code:
print_r($array);
to see the count of each userid (as an array key).

Not tested but you get the idea anyway
__________________
- Richie

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > noob - Php Counting, Sorting, Grouping


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek