I am creating a Like button similar to Youtube or Facebook and I am having some trouble with storing unique likes

I have not started creating the code so I don't have anything to show, but what I am going to create is a simple button after each post on my website that allows users to "Like" the post. The only problem I have is figuring out what my MySQL table should look like for this feat. I want to add a 'rating' column in my 'tbl_posts' table that stores the count, but I'm not sure how to make it so that each user can only upvote the post once. Any ideas on how to create the database in this way?

Also, I want to create the "Like" button using jQuery. What do you recommend is the best way to create the Like button.

Gracias.

Answers


If you're talking about registered users on your page you could create a user_likes_post m:n relation between your post and user tables.

If you're talking about page visitors you'll have to resort to IP addresses and/or cookies to make sure everyone can upvote only once.

For the button itself i'd recommend jQuery UI


I recommend the best way to implement your like button is not to develop a new button, but to use the API:s of facebook to do that.

If you really feel the need to implement it yourself, you should have a UNIQUE column with user id in your SQL table.


Need Your Help

What is the best practice to create MSI with some other child MSI as prerequisite?

wix inno-setup bootstrapper prerequisites burn

Currently we are using Inno Setup as a bootstrapper to install the MSI prerequisites. It makes bit complex to maintain the setup. I found the Burn tool which may help us to resolve this issue by ha...

Changing width of div in % syntax

javascript jquery css

Very simple question, just having trouble with syntax.