Go Back   Cloud Computing > Support > PHP Forum
 

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 08-17-11, 22:24
BOD Member
 
Join Date: Aug 2011
Posts: 76
Default creating a banner exchange script - need help with logic

I was wondering if anyone could help me out in figuring the ratio part of the script. I don't know where to start.

I was thinking of just having an element in a mysql table that would count the number of impressions lets say - up to 100. Then there would be a table to count how many credits have been earned. And then with php when the count reaches 100, the code would add like 50 credits and then restart the count. Is that feasible or is there something more efficient?
Reply With Quote
  #2 (permalink)  
Old 08-18-11, 09:59
BOD Member
 
Join Date: Jun 2011
Posts: 96
Default

If that they have 50 credits per 100 impressions, then let's expect that the number of impressions is kept in a variable $impression_count. Then, the total number of credits available would be floor($impression_count/100)*50. You could keep the total number of credits used in another variable/field and that number would need to be always less than the above equation.

For an example:

Quote:
If you had 250 impression (i.e. $impression_count=248), then you'd have floor(250/100)*50 = floor(2.50)*50 = 2*50 = 100. If they had used 30 credits, then they would have 100-30=70 credits available.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT -6. The time now is 01:14.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright © 1999-2012, BODHost Ltd. All rights reserved.