Jump to content

Counting values and ad to table, with time tracking


xwishmasterx

Recommended Posts

I am in need of suggestions on how too achive this:

 

I have a surf exchange and whenever a member has viewv a site, it ads this members Id and time to a table called vtp_tracking.

 

I have now created a team script, so I can count the total of surf for members within this team from the vtp_table.

 

What I am in need of is this:

I would like to add a bonus for the teams, so my idea was this: every hour run a cronjob to get the results for the last hour by team id lik so:

 

WHERE vtp_members.team_id="teamid" AND vtp_tracking.credit_members_id=vtp_members.id AND vtp_tracking.action_date>date_sub(NOW(),interval 60 minute

 

I believe the above code will work fine and get me the results for team members for the last hour.

 

Problem: how can I get this result, multiple it with the value from another field and divide by 100  and add this to a third field?

 

eg: (result from above * value from other field / 100) then add to a third field.

 

Anyone willing to try and answer this one?

Thats the last part of it..thank you for that!

 

My "REAL" problem is I know how to get the info needed from the database, I just tried my script and it returned:

 

Team 12 has surfed: 3 sites

 

by using this code (end of it)

while ($row = mysql_fetch_array($result)) {
echo "Team ".$row[team_id]." has surfed: ".$row[surfs]." sites";}

 

I don't know how to get these results and then apply you update code.

The math part should be applied to the ".$row[surfs]." result, and then "UPDATE" into table 'teams' where ".$row[team_id]." = team_id

 

I hope I make sense, just started learning php a few days ago.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.