i am building a message system for website.i have two table one store user_detail and other store message sent to each other users. you can see main.jpg file where inbox sent etc.. will be display and action takes accordingly.
$query='select m1.id, m1.title, m1.timestamp, count(m2.id) as reps, user_detail.user_id as userid, user_detail.username from pm as m1, pm as m2,user_detail where ((m1.user1="'.$inbox_req_param['pm.user_id'].'" and m1.user1read="yes" and user_detail.user_id=m1.user2) or (m1.user2="'.$inbox_req_param['pm.user_id'].'" and m1.user2read="no" and user_detail.user_id=m1.user1)) and m1.id2="1" and m2.id=m1.id group by m1.id order by m1.id desc';
i am executing above query prob is that there are two records sent by user_id 99 to 100 and one record by user_id 100 --> 99.when i am login with different user account then it is showing both user records?
how to achive this. is my db is desing properly.