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 6793311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:05:08+00:00 2026-05-26T18:05:08+00:00

My website has a users search where a user can search for other users.

  • 0

My website has a users search where a user can search for other users. I would like for that search to show all friends first, and when there are no friends found, other users. But to do that, I have to run a few db queries on every keyup. The query for friends is somewhat complicated, because there types of friends and believe it is not good for performance to use it all the time, but to get all people by search is a very basic query.

Now I would like to keep those friends in a variable, but I’m getting lost. What would be the best way to do that. I’m already storing info about user with friends in a $_SESSION, but it would be awesome to have that client side. I’m considering storing that in a cookie, but am wondering if that will fit in those 4kb if I try to store an array with like couple hundreds users. What would be the best way to implement that? Any thoughts?

  • 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-26T18:05:09+00:00Added an answer on May 26, 2026 at 6:05 pm

    Do you use a cross reference table in the DB to keep track of who is friends with who? I think that’s a good way to solve it if you don’t and then you’d only have to query this table to get the friends.

    ...because there types of friends...
    Does this mean that there are different types of friends?

    Simplified you could have a table with three columns: person_id, friend_id, friend_type (if that was needed). Person_id and friend_id are references to the same type of id. When two people become friends you add their id’s to the table and what type of friends they are.

    If you really want to do this on the client side I guess localStorage could be something to look in to, but it might not be supported by all browsers. localStorage can take around 10MB (if I’m not wrong) of storage. Load the list of friends when a user enters the site the first time. I’d probably go for a session on the server side but that’s just my opinion.

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

Sidebar

Related Questions

I've got a website that has a form that the user can type in.
Building a website that has English & Japanese speaking users, with the Japanese users
Ok, so I'm building a website that has client profiles. A web user finds
I have a classifieds website, and users can search ads. The results are displayed
Our website has one section which often changes to match the user. (examples are
my website has a log in by open id feature. When a user logs
We have not purchased an SSL certificate so the user of our website has
A programmer I know has a website that is fully Standards Compliant. It uses
Has anybody used or seen a website that uses FlapJax to function, rather than
I have a real estate website that has several categories. And i want the

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.