Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 725591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:21:15+00:00 2026-05-14T06:21:15+00:00

I have created a site where people can create a profile. But I am

  • 0

I have created a site where people can create a profile. But I am trying to figure out how to start on making an add friend button so users can have friends.

In my user table, i have user_id, first_name, last_name, email, etc.

Should I somehow relate the user_id of the user and the friend in a friend table?

I am a novice to programming, so these things are still new to me. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:21:16+00:00Added an answer on May 14, 2026 at 6:21 am

    Well, let’s try to keep this simple.
    You’re trying, essentially, to find a way to connect two users together.

    Since I’m trying to keep things simple, and definitely not implying that this is the best way of doing it, I think the easiest way to go about doing this is to create a new table (users_friends) with the following fields: (user_id) and (friend_id).

    Well, so let’s say my user_id is 5.
    Your user_id is 10.

    I want to add you as my friend, therefore I’d add an entry to that newly created table with the following values:
    user_id = 5, friend_id = 10.

    So, let’s say you want to display all of my friends, you could run a query such as:

    SELECT * FROM `users` WHERE `user_id` IN ( SELECT `friend_id` FROM `users_friends` WHERE `user_id` = '5' );
    

    Sure enough, removing a friend is easy, all you have to do is delete the entry from the newly created table …

    DELETE FROM `users_friends` WHERE `user_id` = '5' AND `friend_id` = '10';
    

    And poof, you’re suddenly not my friend anymore 😉

    So yeah, these are the basics.
    I’d try this solution before moving on to a solution which will allow you more flexibility.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a video site where people can comment under each video. I'm trying
I have created a page on my site where users can post directly to
On my site, people can buy parts for vehicles. I want to create a
I have been making plans to create a site that would contain several different
I've a site where people login and a SESSION is created. I have noticed
I am trying to create a link that people can put on their own
i have created a website for a non profit organization. People on the site
I have created a site collection inside a web application with user A as
Well as I have posted earlier too...I have created a site in two languages.One
I have created my first site and put alot of time into it and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.