Idea/approach: adding data on database when condition met
Posted: Mon Jun 13, 2016 11:19 pm
I am trying to add some line of code on my website, maybe "require_once( 'point_counter.php' );".
Every client has details "user" table (name,email,totalproduct, totalsales, totalwithdrawn etc..)
Now I am adding one column to the database table and name it as 'total points':
What I would like to do:
In the code 'point_counter.php', when a user login successfully, it adds points to the database when conditions met:
e.g:
-A = if user has active products add +20 to the total points.
-B = if user completed withdrawal then add +20 to the total points.
-and some other conditions.
My problem is, what if the user login (first) then met the A condition (added 20 points), Then logout and login again(second) and so on..(probably it will add and add again and again).
What would be the logic that when A condition already met or already added points then It will not add again. Instead , jump to other conditions that had no points.
What is the best approach to do this with only 1 column to the database for points.
Every client has details "user" table (name,email,totalproduct, totalsales, totalwithdrawn etc..)
Now I am adding one column to the database table and name it as 'total points':
What I would like to do:
In the code 'point_counter.php', when a user login successfully, it adds points to the database when conditions met:
e.g:
-A = if user has active products add +20 to the total points.
-B = if user completed withdrawal then add +20 to the total points.
-and some other conditions.
My problem is, what if the user login (first) then met the A condition (added 20 points), Then logout and login again(second) and so on..(probably it will add and add again and again).
What would be the logic that when A condition already met or already added points then It will not add again. Instead , jump to other conditions that had no points.
What is the best approach to do this with only 1 column to the database for points.