The Little Guy Posted August 23, 2010 Share Posted August 23, 2010 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)? Quote Link to comment https://forums.phpfreaks.com/topic/211460-like-dislike-buttons/ Share on other sites More sharing options...
Garethp Posted August 23, 2010 Share Posted August 23, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/211460-like-dislike-buttons/#findComment-1102535 Share on other sites More sharing options...
The Little Guy Posted August 23, 2010 Author Share Posted August 23, 2010 That is exactly what I was planning on doing! Quote Link to comment https://forums.phpfreaks.com/topic/211460-like-dislike-buttons/#findComment-1102563 Share on other sites More sharing options...
xeronix Posted August 30, 2010 Share Posted August 30, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/211460-like-dislike-buttons/#findComment-1105100 Share on other sites More sharing options...
pornophobic Posted September 4, 2010 Share Posted September 4, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/211460-like-dislike-buttons/#findComment-1107071 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.