Jump to content

Please help me to correct this query


sledjama

Recommended Posts

Hello, I am working on a facebook style news feed, the feed you get to see when when you login to facebook that shows posts made by you and your friends.

 

i am able to get posts made by friends with this query

 

select members.username, wallpost.idx, poster_id, `post`, wall_id, `time`, member_info.picture from wallpost, member_info, members, friends  where (( poster_id=friends.friend1_id and friends.friend2_id=?) or (poster_id=friends.friend2_id and friends.friend1_id=?)) and member_info.user_id=wallpost.poster_id and members.id=wallpost.poster_id order by idx desc LIMIT 0,50

getting data from 4 tables to fulfill what i want but it does not show posts made by me

my id will be inserted where the question marks are.

 

select members.username, wallpost.idx, poster_id, `post`, wall_id, `time`, member_info.picture from wallpost, member_info, members, friends  where (( poster_id=friends.friend1_id and friends.friend2_id=?) or (poster_id=friends.friend2_id and friends.friend1_id=?) [b]or poster_id=?[/b]) and member_info.user_id=wallpost.poster_id and members.id=wallpost.poster_id order by idx desc LIMIT 0,50

 

adding the bolded part helped but it fetched dupplicates of my own posts while posts from friends is fine.

 

thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/248001-please-help-me-to-correct-this-query/
Share on other sites

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.