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

The Archive Base Latest Questions

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

I have a website where users can rate comments that are left on pages.

  • 0

I have a website where users can rate comments that are left on pages. Each comment has a unique ID (E.g. 402934) If I want users to be able to thumb-up/thumb-down said comments I can see how I would make a simple counter code to keep track of the number of thumb-ups vs thumb-downs but how can I make sure that each user only ranks said comment once. I was going to make a database with each comment number as a row and in that row having an array of all the users that have ranked it thumbs up and all the users that have ranked it thumbs down but I had a feeling that wasn’t the best way. My next thought was to have a table for each user and then having an array showing all the comments said user has ranked. It would probably run faster this way (e.g. checking from a user’s 150 rankings verse a comment’s 6050 rankings but I still feel like there is a better way… any ideas?

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

    Create a new table with user_id, comment_id and vote TINYINT(1).

    A value of 1 in vote is a thumbs up, A value of 0 in vote is a thumbs down.

    Have a UNIQUE KEY constraint on (comment_id, user_id).


    If you follow the above it will be easy to check whether a user has cast a vote on a specific comment, if you’d like to be able to quickly (as in fast execution) see all the comments a user has made you should also add an INDEX to user_id.


    When a user votes you could use REPLACE INTO to user_comment_thumbs, such as the below:

    REPLACE INTO `user_comment_thumbs` (user_id,comment_id,vote)
    VALUES (@user_id, @comment_id, @vote);
    

    If the user has already made a vote the entry in the table will be updated, otherwise a new row will be inserted.

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

Sidebar

Related Questions

I want my website to have a checkbox that users can click so that
I have a website where users can create new topics. Each topic has a
I want to create a website with various users. The users can have different
We have some files on our website that users of our software can download.
i own a website where users can vote/rate things and i want to improve
I have a website the users can do stuff like leave comments, perform likes,
I have a website that stores quotes and users can add some quotes to
I have a website where users can Like and Dislike items. So for each
Imagine that we have a website where users can read articles, view photos, watch
I have a website where users can upload their files; these are stored on

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.