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

  • Home
  • SEARCH
  • 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 7546145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:07:28+00:00 2026-05-30T09:07:28+00:00

For example, 10 results are displayed from MySQL table products and each product has

  • 0

For example, 10 results are displayed from MySQL table products and each product has a like and dislike button. If the user presses like or dislike, the voted table is updated.

Now what i’m having trouble with is: What is the right way of checking if the user has voted or not? What to store If product has been voted with like or dislike?

If there is 300 results, I don’t want to do 300 queries to check in the voted table if the productid and userid is present. What would be the correct way of doing this? I still want to show the results, just not the like or dislike button if the user has voted.

  • 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-30T09:07:29+00:00Added an answer on May 30, 2026 at 9:07 am

    Table A stores products, e.g.

    id | product |
    

    Table B stores user votes, e.g.

    id | user_id | product_id | vote (like/dislike)
    

    Then you can do a simple join query

    SELECT `A`.`id`, `A`.`product`, `B`.`vote` from `A` LEFT JOIN `B` on `A`.`id` = `B`.`product_id` WHERE `B`.`user_id` = $current_user_id_value;
    

    Then the result set will look like this

    id |   product   |   vote   |
     1 | "product 1" |  NULL    |
     2 | "product 2" |  like    |
     3 | "product 3" |  dislike |
     4 | "product 4" |  NULL    |
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a regex that will give me the following results from each example
I have a simple HTML table display of data that results from an MySQL
I want to be able to search through a MySQL table using values from
I currently am using mysql and php to display 9 random results from my
I have a table of results I'd like to display: | change | position
I have mysql search results from a keyword search being performed on my site.
I'm using three mysql tables that looks like: The table for members accounts |
I have a script below which reads on displayed information from my mysql database
I am working from this example: http://jqueryui.com/demos/autocomplete/#remote and I am encoding the output like
I'm writing a calculator currently and I'd like to have results displayed in a

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.