Skip navigation
Currently Being Moderated

'Like' or Thumbs Up system.

Apr 17, 2012 8:37 PM

How would I go about creating a 'like' system for entries? I'm creating a mini-blog system off of a guestbook format.

 

Basically I figure a star rating system for each post would be tricky. I just want something where a user would click a link under the post, it would store information in the database every time somebody clicked it, and then display the number of clicks back on the post. I'd also like to stop users from liking the post more than once if possible.

 

I am fairly new to this but I'm not just looking for code, I want to know how to do it myself.

 

Thanks.

 
Replies
  • Currently Being Moderated
    Apr 18, 2012 5:11 AM   in reply to Abidubbah

    Create a user vote table with user id and post id as the primary key.  That will prevent double entries.  When the user selects the voting image, go to a page that inserts your record.

     

    If you want to be thorough, you can also allow people to not like something. 

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2012 5:15 AM   in reply to Dan Bracuk

    Depending on what database engine you're using, you could use the MERGE statement, certainly works in SQL Server. It's basically an INSERT or DELETE depending on whether the data's already there or not, which would absolutely prevent duplicates without the need for doing a separate SELECT statement.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2012 11:00 AM   in reply to Abidubbah

    I've heard good things about the books, "Database Design for Mere Mortals" and "Teach Yourself SQL in 10 Minutes".  The nature of your questions suggests that you don't know very much about databases.

     

    That's ok though.  We are all new at least once.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points