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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:45:30+00:00 2026-05-26T13:45:30+00:00

On my site I allow the users to select what they like or have

  • 0

On my site I allow the users to select what they like or have interest in. This is done using a pre-defined drop down menu, so every time the user logs into the site they get a list of users that have the same interest as them.

This is done by taking the logged in user’s interests (store in db) and matching with other user on the site, using MySQL WHERE clause. But what I am having trouble is how to show percentage or score next to each users to show how close they match the logged in user interest.

For example:

  • user1 — 60% match to your interest
  • user1 — 30% match to your interest
  • user2 — 20% match to your interest

Each user have 5 different interest, if all match than its 100% match.

A sample of table structure:

CREATE TABLE IF NOT EXISTS `helloworld` (
  `id` int(9) NOT NULL AUTO_INCREMENT,
  `like1` varchar(300) NOT NULL,
  `like2` varchar(300) NOT NULL,
  `like3` varchar(300) NOT NULL,
  `name` varchar(300) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

example query:

SELECT * FROM helloworld WHERE like1='football' AND like2='art'

I was thinking using COUNT function, but I am unsure? or should I be using sub queries?

EDIT : i am using PHP for server side language. user can NOT type their own likes, must use the pre defined list.

  • 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-26T13:45:31+00:00Added an answer on May 26, 2026 at 1:45 pm

    Here’s how I do it. Assume that $like1, $like2 and $like3 are the values from your current user:

    SELECT (IF(like1='$like1',1,0) + IF(like2='$like2',1,0) + IF(like3='$like3',1,0))/3*100 match_percent,
    COUNT(id)
    FROM helloworld
    GROUP BY match_percent;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to add some functionality to a site that would allow users to
I'd like to allow users on my site to preview their posts before submitting
I have users creating lists in my site and I'm using the generic CreateView
I've got a PHP-based site where we allow users to upload a comma-separated text
To allow users and site admins to view/add/edit/delete data in my application I decided
I'm trying to allow users to post videos on my site by supplying only
My asp.net site allows users to pick the theme they want from a list
I have a site that allows users to vote on images. Each image has
I am using a wordpress plugin called GD Star Rating to allow my users
I have a screen which allows users to add several categories at once. They

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.