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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:27:22+00:00 2026-05-16T18:27:22+00:00

I am making an autosuggesting function, when the user writes something in the field

  • 0

I am making an autosuggesting function, when the user writes something in the field it stores it in:

$queryString = $db->real_escape_string($_POST['queryString']);

I want it to autosuggest after the users friends. The user´s friends is in users_friends, but only the friend´s ID. Now their full_name is in the table “users”. And i want when you search it should in users for the full_name + check if its friends with the user.

As you may understand i do not expect all my users to know eachother id´s so writing e.g “52” “233”, but searching for their full_name s.

UPDATE:

I know tried doing this:
$query = $db->query(“SELECT uf.bID
FROM users friends, users_friends uf
WHERE uf.uID = ‘1’ AND uf.type = ‘friend’ AND friends.full_name LIKE ‘$queryString%’ LIMIT 10;”
);

It selects the bID, from the users friends WHERE the userid is 1 and are friend.

Now i start to see some results i think. When i write a full_name that im friends with, i get the id of the user(the id that is stored in bID). Now i just need to grab the full_name in “users” where id = bID..

table: users
id | full_name

table: users_friends
id | uID | bID

So conclusion of all this (trying to make a better summary in order to make you understand better: )

When you type in e.g Jack in the search field, then the $queryString is now “jack”. Then it is taking “Jack”(full_name in users), grabbing his id(id in users), if he exists there ofcourse, and then match it with bID (in users_friends) where uID is $USER; ($user is the current user that are logged in´s id.)

Hope this was easier to understand, please leave comment if theres something unclear.

  • 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-16T18:27:22+00:00Added an answer on May 16, 2026 at 6:27 pm

    So, as i figure it out, you’ve got the current user’s id in $USER and its query string in $queryString, and what you want is the names of the user’s friends based on the $queryString, am I right?

    So, assuming the database’s schema is as you’ve put:

    table: users
    id | full_name
    
    table: users_friends
    id | uID | bID
    

    See if this query works out for you, then:

    SELECT users.full_name 
    FROM users INNER JOIN users_friends ON users.id=users_friends.uID
    WHERE bID=$USER AND users.full_name LIKE '$queryString%'
    LIMIT 10;
    

    Where $USER and $queryString are your variables.

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

Sidebar

Related Questions

After making some changes in my models (eg. new field in a model and
Making a new site but something is happening to it in IE8. The social
Making a new site but something is happening to it in IE. I've purchased
Making a simple application, so when the user logs out of Windows, it of
Making a mobile friendly site, I have a single field and a submit button.
Making an Flex App. Just wondering if anyone has created something that fits automatically
Im making slide show with jquery How i can set interval between two function
Does making a class field volatile prevent all memory visibility issues with it in
Im making a simple Androidgame , where the user selects an answer to a
Making a ternary logic table, and I would like to make my own function

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.