chomedey Posted April 29, 2010 Share Posted April 29, 2010 Hello all, I am continuing to experiment with the new facebook functionality, and have run into a new challenge for which I am woefully unprepared. I have a MySQL query that looks like this: $query = "SELECT *, DATE_FORMAT(date_entered, '%e %M, %Y') as newdate FROM data WHERE deleted='N' ORDER BY date_entered DESC LIMIT $start, $display"; Once I have these results returned, however, I want to limit them further by seeing a) which rows have the visibility column set to 'friends' and then b) which of these rows has a userID (which is a facebook subscriber ID) that is in an array ($friends) that contains all the userIDs of the current logged_in user's facebook friends (fb has made all this data accessible now with their new Facebook connect endeavor). So I want to do a MySQL query, limit the results by selecting only those rows that have a userID that appears in an array, and then echo those rows. Also, how do I look for the userID in only certain parts of an array i.e. I want to match my needle to only the "id" key (?) in this haystack: array(218) { [0]=> array(2) { ["name"]=> string(13) "Harold Robbins " ["id"]=> string(7) "5244442" } [1]=> array(2) { ["name"]=> string(13) "Joey De Francesco" ["id"]=> string( "13600096" } etc. Any help much appreciated. Cheers. Julian Link to comment https://forums.phpfreaks.com/topic/200223-limiting-results-of-mysql-query-with-in_array/ Share on other sites More sharing options...
otuatail Posted April 29, 2010 Share Posted April 29, 2010 tyy "SELECT * FROM table LIMIT 10"; Link to comment https://forums.phpfreaks.com/topic/200223-limiting-results-of-mysql-query-with-in_array/#findComment-1050731 Share on other sites More sharing options...
chomedey Posted April 29, 2010 Author Share Posted April 29, 2010 I didn't explain myself clearly enough. Not all the data is contained in my database. Some of it is coming from fb (the data that tells me the userIDs of the fb friends of the currently logged in user). So I have to go to my db to get my data, then compare it to an array obtained from fb's database, and then echo the results. So a simple LIMIT or WHERE clause on my MySQL query will not cut it. Thanks. Julian Link to comment https://forums.phpfreaks.com/topic/200223-limiting-results-of-mysql-query-with-in_array/#findComment-1050733 Share on other sites More sharing options...
chomedey Posted April 30, 2010 Author Share Posted April 30, 2010 Figured it out - didn't know you could put an array as a variable in a mysql query. Thanks. Julian Link to comment https://forums.phpfreaks.com/topic/200223-limiting-results-of-mysql-query-with-in_array/#findComment-1050833 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.