I have 2 tables:
Friends
ID | Profile | Check
------+-----------+---------
int | int | bool
Where ID
is person who sent original friend request, Profile
is ID of person request was sent to, and Check
is 0 = request pending; 1 = request accepted.
Messages
OwnerID | ...
-----------+-------
int | ...
Where OwnerID
is ID of member who wrote the message.
So basically, what I am looking at is first:
select all rows from friends_list table where ID or Profile is equal to the memberID cookie. BUT heres my plight: If I send another user a friend request, then my ID is placed in the ID field and their ID is placed in the Profile field of the friend_list table. But if another user requests a friend request from me, then my ID would go into the Profile field and theirs would go in the ID field.
So, I would have a row where ID = 1, and Profile = 2. And the next row would be ID = 3 and Profile = 1. Now, both users with IDs 2 and 3 are friends of mine (ID 1), So I need to show all messages from 1, 2, and 3 (mine and my two friends) where check = 1