Following query where I am trying to display post on my friends profile but it display on both of my friends and not friend from user table
my database structure is,
Friends_details
Friend_id----Profile_id------Friend_with
1----------------1---------------- 2
2---------------- 2 ---------------- 1
3 ---------------- 1 ---------------- 3
4---------------- 3---------------- 1
5---------------- 4---------------- 3
6---------------- 3 ---------------- 4post_details
post_id---------------- profile_id--------------- Frind_id1---------------- 1---------------- 1,2
2---------------- 2---------------- 1,2
3---------------- 3---------------- 3,4,5,6
4---------------- 4---------------- 5,6Img_post_details
Image_id---------------- Post_id
1---------------- 1
2---------------- 2
3---------------- 3
4---------------- 4
$fid[]=$row_post['frnd_id'];
//echo $fid;
foreach($fid as $frnd)
{
$excludes=explode(',',$frnd);
//print_r(explode(',' ,$frnd));
//\$a=print_r($excludes);
$query_img="SELECT * FROM upload_post.post_details pd
INNER JOIN upload_post.image_post_details ipd
ON pd.post_id = ipd.post_id
INNER JOIN social_panel_db.friends_details fd ON fd.friends_id=pd.frnd_id
WHERE pd.profile_id=".$rows['profile_id']." OR pd.profile_id=".$_SESSION['pro_id']."
AND fd.req_friend_profile_id IN(".$frnd.") OR fd.profile_id IN(".$frnd.") AND fd.frend_request_status=2 AND fd.profile_id=".$_SESSION['pro_id']." OR fd.req_friend_profile_id=".$_SESSION['pro_id']." order by pd.post_id desc";
}