Jump to content

Like / Dislike buttons


The Little Guy

Recommended Posts

I am adding like/dislike buttons to my comments section, and am not sure how I should do this.

 

I have two thoughts:

1. have a like/dislike table that holds all likes and dislikes

2. have a column in the comments table that holds the number of likes and a column with number of dislikes.

 

I am liking #1 the best, it seems more practical and modifiable. What do you think? I also want to place on the top of the comments section the best rated comment.

 

What do you think I should do (#1, #2 or other)?

Link to comment
https://forums.phpfreaks.com/topic/211460-like-dislike-buttons/
Share on other sites

I'd have a table called "Likes"  that held a row for each like and dislike, that stored the like or dislike as boolean (0 for dislike) and a column for UserID and a column for CommentID. How many likes or dislikes per comment should be derived from how many rows have that comment id in it's CommentID and has a 0 or 1

Either would be good,

 

I personally would make my own table and store the CID (Comment ID) L and D (Like and Dislike) as a boolean variable, then PID (Person ID) to keep track of if people are flaming your comments. The only problem with this, is that the server has to add up all the likes and dislikes, however, as long as your site doesn't have a huge overhead, you should be fine.

The way I'd do it is for everything posted on my application, it gets a unique id # for each item. Then my table fields would be item_id, (item contents, etc), is_likeable.

 

If the is_likeable is true, then you can have a second "likes" table with the fields: item_id, likes, user_like, dislikes, user_dislike. That way you can tell who liked/disliked which item.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.