var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Search users
I am making a kind of dating site. Users can add friends and here i have a problem.
When the user types a letter of the name they are searching for in the input box. There is a request made to my php file that returns 6 users that contain the letters of the user input.
I use this query to search for users:
The problem is that the users that are already friends also are returned.
select id_user, username from users where username like '%".mysql_real_escape_string($find_user_name)."%' LIMIT 6
Table users: id_user, user_name, email, ..., ....
Table friends: users_id_user, friend_id
I thought about making a view of users and then removing the ids that are in my friend_id and then use the view to search for new friends. Is there a better way of doing this?
Thanks in advance!
you can join the friend table in your query
from user u
left join friend f on f.user_id = u.user_id
f. friend_id is null --so you can see when user has no friends
and username like '%".mysql_real_escape_string($find_user_name)."%'