I have table friends and table users
All the ids in friends table (user_one, user_two) are valid users from table users
Lets says a current LoggIn user visit another user's profile and the profile id which he visited is 27
Please Note: I am using the $_GET global variable to get this profile id. e.g
$user_id = $_GET['id'];
then he click on a link to view the friends of this user(27)
so now his friends are:18 and 33
Please how can I query database if current(18) user is also friends with user 33 ?
Note: user 18 is the current LoggIn user
below is clear friends table structure:
u1 | u2
18 | 33
33 | 27
27 | 18
below is my code i tried :
SELECT IF(user_one = '$IsLoggIn' OR user_two = '".$_GET['id']."', user_two, user_one)
FROM friends
WHERE ((user_one = '$IsLoggIn' OR user_two = '".$_GET['id']."') OR (user_two ='$IsLoggIn' OR user_two = '".$_GET['id']."')
Please am new to sql. Thank you