xwishmasterx Posted April 8, 2011 Share Posted April 8, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/233091-counting-values-and-ad-to-table-with-time-tracking/ Share on other sites More sharing options...
Pikachu2000 Posted April 8, 2011 Share Posted April 8, 2011 You mean like this, or have I missed the point? UPDATE table SET field1 = ( field2 + (field3 * field4 / 100) ) WHERE . . . Quote Link to comment https://forums.phpfreaks.com/topic/233091-counting-values-and-ad-to-table-with-time-tracking/#findComment-1198795 Share on other sites More sharing options...
xwishmasterx Posted April 8, 2011 Author Share Posted April 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/233091-counting-values-and-ad-to-table-with-time-tracking/#findComment-1198813 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.