|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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.. |
|
#2
|
|||
|
|||
|
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); Not tested but you get the idea anyway
__________________
- Richie |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > noob - Php Counting, Sorting, Grouping |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|