Jump to content

Limiting results of MySQL query with in_array?


chomedey

Recommended Posts

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(8) "13600096" }

 

etc.

 

Any help much appreciated.

 

Cheers.

 

Julian

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.