I want to do a contacts page. Here is my table structure:
Accounts Table:
1) id
2) User_id
3) Full_name
4) Username
5) Email
6) Password
Contacts Table:
1) My_id (This is the user who added friend_id)
2) Contact_id (this is the contact who was added by my_id)
3) Status
My query looks something like this:
$sid = ID of user who is viewing;
$sql = "SELECT STRAIGHT_JOIN DISTINCT contacts.contact_id,
accounts.full_name FROM contacts INNER JOIN accounts
on contacts.contact_id = accounts.user_id WHERE
contacts.my_id = '$sid' OR contacts.contact_id = '$sid'";
The problem is that it doesn’t work the right way. I end up seeing my name in the query (meaning when i login i see my name in the contacts instead of contacts name).
How to fix this? Thanks.
This query ought to suffice: