Woot-badge like in PHP

帅比萌擦擦* 提交于 2019-12-05 00:17:51

问题


Does anybody knows how to implement something into a website written in PHP, similar to the Woot-badge and the Fanatic-badge on stack overflow? I want to reward my users if they visit my site everyday for 75 days, without days they don't visit it. My site uses sessions for log ins. And I use a MySQL database.

The users table now looks like this:

COLUMN NAME        TYPE
id                 integer
username           varchar
password           varchar
email              varchar
(7 columns with privacy settings) integer
lastvisit          integer
lastlogin          integer

回答1:


Pseudo-code:

switch last visit
   case yesterday
      increment counter by 1
      set last visit to today
      if counter == 75
          award badge
   case more than a day ago
      set counter to zero
      set last visit to today


来源:https://stackoverflow.com/questions/1166465/woot-badge-like-in-php

标签

工具导航Map