I'm currently working on a website with different sections which looks like this:
Every Section has an image which you can like / dislike - something similar to facebook
What I want to have is, if someone press on like / dislike button, the like counter value in my database should be increased by 1. But, that's not the problem, i know how to to that...
My Problem:
How can I give that section with the image an unique ID (I thought I can get the ID of the image from the Database and add this value to a hidden field in my section). Next i bind an onclick
to both buttons (like / dislike) and read the value of my hidden field (the ID) in the section. With this ID i can increase my vote counter with a DB query - which look then something like this:
UPDATE xxx SET upvotes = upvotes + 1 WHERE ID = $valueOfTheHiddenField
same on dislike
UPDATE xxx SET downvotes = downvotes + 1 WHERE ID = $valueOfTheHiddenField
I don't know if that's the correct method to do this, but that were my ideas on how to do that.
Please correct me if I'm wrong or tell me the "best" way how to solve this.
thanks for your inputs :)