0

I'm trying to display the number of friends a user has using my app. I've figured out through FQL how to pull out an array of the users friends using the app.

SELECT uid,name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) AND is_app_user=1

Right now, it pulls up an array when displayed. I'm trying to just display the result as a single numerical value. I'm coding in PHP. Anyone know where I need to go from here?

  • Assuming you actually don't need the names, just the count, using `SELECT ''` will lower the bandwidth usage. – kba Dec 10 '11 at 01:44

2 Answers2

0

Select count(*) perhaps.

SELECT count(*) FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) AND is_app_user=1
savinger
  • 6,544
  • 9
  • 40
  • 57
  • 1
    Not with FQL -- it's different from SQL. See [this SO post](http://stackoverflow.com/questions/2841569/fql-result-count) –  Dec 10 '11 at 01:14
  • @rdlowrey Ah, oh well. Just took a guess. – savinger Dec 10 '11 at 01:15
  • 1
    Be careful ... while I don't do it, there are some SO trolls who love nothing more than to downvote speculative answers that otherwise seem logical :) –  Dec 10 '11 at 01:17
0

print count($array); should return the amount of entries in the array

animuson
  • 53,861
  • 28
  • 137
  • 147
Serge Bekenkamp
  • 416
  • 4
  • 13