PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Jun 05, 2020 2:25 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Jun 13, 2016 11:19 pm 
Offline
Forum Newbie

Joined: Thu Jun 09, 2016 9:01 pm
Posts: 14
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.


Last edited by xkevin on Tue Jun 14, 2016 12:46 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Mon Jun 13, 2016 11:29 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA
The points should be updated when the events happen: when they get active products and when they complete withdrawals. When you add this column you set it to have the correct number of points at the same time (ie, ALTER to add the column then UPDATE to calculate the correct points). Nothing should need to happen just because they logged in.


Top
 Profile  
 
PostPosted: Tue Jun 14, 2016 12:55 am 
Offline
Forum Newbie

Joined: Thu Jun 09, 2016 9:01 pm
Posts: 14


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group