hello guys am creating site were all users can post for there friends to see ans coment just like facebook where am having problem is how to make sure only a users friends can see there post not the whole site members i have table in my database called post where all post are queried from and displayed on the page according to there date of post i dnt know how to remove the post of non friends from being visible to every one just the way facebook is thanks

Well it is difficult to answer properly without seeing what you have done so far but I would have a friends table that will hold the ids of users with related ids of their friends and then you can just cross reference that table to match friend ids with user ids stored with your posts

Sorry but I don't want to download your code and go through it all - I want you to post the relevant sections of code on here

1) You have a column named 'friend_ids' which contains a comma-separated list of friend IDs, like so: "1378,1892,461,1781".
2) Your posts table uses user_id as a column to identify who made the post.
3) You have a local variable named $user_id that holds the id of the current user

Here's an example of a query to fetch only posts belonging to friends of the current user:

SELECT * FROM posts WHERE user_id IN(SELECT friend_ids FROM users WHERE user_id=$user_id)
Member Avatar

Re: simplypixie's comment

Agreed: in order to make this thread useful for anybody else with a similar query, please post your code here. Asking contributors to download an 'untrusted' file is asking too much. Posting your SQL tables and php manipulation code along with any current html forms would be useful.