Adding a user to friends

How to make one user can add another to friends?

Answer 1, Authority 100%

We make a table friend_requests {id,r_from,r_to,r_accepted}

When clicking on “Add” Create an entry in it (R_accepted = 0), i.e. We make an application for adding.

It is displayed in the second (“SELECT * FROM friend_requests WHERE r_to=$myID AND r_accepted=0;“), if it takes it – we put R_accepted = 1;

Next to see all friends as possible: “SELECT * FROM friend_requests WHERE (r_from=$myID OR r_to=$myID) AND r_accepted=1;