steviez Posted May 3, 2010 Share Posted May 3, 2010 Hi, I am working on a new feature for my download site where users will get a certain ammount of cash per 1000 download of a file how can i make it so that the cash ammount only gets added every 1000 downloads? for example $6 per 1000 downloads So far my code looks like: if($file['file_size'] >= 5242880 && $file['downloads'] >= 1000) { // update database and add earnings mysql_query("UPDATE uploads SET earnings = earnings+".$config['file_earnings_5_50']." WHERE file_id = '".$file['file_id']."'"); } Any help would be great! Link to comment https://forums.phpfreaks.com/topic/200597-calculation-help/ Share on other sites More sharing options...
newbtophp Posted May 6, 2010 Share Posted May 6, 2010 $file['downloads'] / 1000; if($file['file_size'] >= 5242880 && $file['downloads'] >= 1000){ $earnings = $file['downloads'] / 1000; mysql_query("UPDATE uploads SET earnings = earnings+".$earnings." WHERE file_id = '".$file['file_id']."'"); } Link to comment https://forums.phpfreaks.com/topic/200597-calculation-help/#findComment-1054290 Share on other sites More sharing options...
iblood Posted May 6, 2010 Share Posted May 6, 2010 Just have to modify newbtophp's post if($file['file_size'] >= 5242880 && $file['downloads'] >= 1000){ $earnings =( $file['downloads'] % 1000) * $earning_per_1000; mysql_query("UPDATE uploads SET earnings = earnings+".$earnings." WHERE file_id = '".$file['file_id']."'"); } HTH Link to comment https://forums.phpfreaks.com/topic/200597-calculation-help/#findComment-1054339 Share on other sites More sharing options...
travis Posted May 24, 2010 Share Posted May 24, 2010 if ($file['file_size'] >= 5242880 && $file['downloads'] % 1000 == 0) // update database and add earnings mysql_query("UPDATE uploads SET earnings = earnings+{$config['file_earnings_5_50']} WHERE file_id='{$file['file_id']}'"); Link to comment https://forums.phpfreaks.com/topic/200597-calculation-help/#findComment-1062421 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.