开发者

Customer wants a Relate button like a Facebook Like button

A customer wants a button that says "Relate" that would be kind of like the Like button in Facebook. It would show how many people clicked the button inside an article. Is there an easier way to do this besides creating开发者_如何转开发 a table in MySQL and use PHP?


I suppose you could use a CGI script written in bash that read/writes a plain text file that stores the click count. But one way or another you're going to have to have some kind of server-side handling and data storage. Doesn't have to be PHP/MySQL, but you'll have to use SOMETHING.


If you want to use data gathered across multiple sessions by multiple people, you're going to need to store that data. Whether you store it using databases, textfiles, or carve it in a tree is up to you.


Yep, instead of creating a new table, just add a column likes INTEGER(11) to articles table. Whenever someone clicks the "relate" button just add count by one.

You may also want to disable button after user has clicked it. You may want to store the info liked:article_id in cookie to make sure user do not adds fake "relates", unless he clears cookie. But tracking logged in user is different (but more appropriate) game.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜