Adil Posted August 14, 2009 Posted August 14, 2009 In my cron_day.php, I want it so that the bank gives 5% interest a day but the maximum interest it gives is 1,000,000. This is the code I have so far: $db->query("UPDATE users SET bankmoney=bankmoney+(bankmoney*0.05) where bankmoney>0"); Is there anyway I can do it so max is 1mil? Quote
Lithium Posted August 14, 2009 Posted August 14, 2009 Re: Max Bank Interest yes... use IF statements on the query Quote
Adil Posted August 14, 2009 Author Posted August 14, 2009 Re: Max Bank Interest Thanks. Ive done it now. Quote
Lithium Posted August 14, 2009 Posted August 14, 2009 Re: Max Bank Interest you mind showing the outcome? :) Quote
Haunted Dawg Posted August 14, 2009 Posted August 14, 2009 Re: Max Bank Interest mysql_query('UPDATE `users` SET `bankmoney` = `bankmoney` + (IF((`bankmoney` * 0.05) > 90000000), 90000000, (`bankmoney` * 0.05))) WHERE `bankmoney` > 0'); Should work Quote
Adil Posted August 15, 2009 Author Posted August 15, 2009 Re: Max Bank Interest Thanks. I found another way to do it before you posted that but im sure that would have worked fine. Thanks for trying to help. Quote
Haunted Dawg Posted August 15, 2009 Posted August 15, 2009 Re: Max Bank Interest What's your "way"? Quote
Adil Posted August 15, 2009 Author Posted August 15, 2009 Re: Max Bank Interest Well basically my bank gives 5% interest a day. And if you have 20mil in the bank, interest is 1mil. (as 5% of 20mil is 1mil). So I did an if statement so if the bank money is higher than 20mil, it adds 1mil to bank money, else it adds the usual 5%. Quote
Adil Posted August 15, 2009 Author Posted August 15, 2009 Re: Max Bank Interest This is weird. On my testing server account this works fine but on the actual site it doesnt work. This is the code in cron_day.php $is=$db->query("SELECT * FROM users"); $ir=$db->fetch_row($is); if($ir['bankmoney'] > 20000000) { $db->query("UPDATE users SET bankmoney=bankmoney+1000000 where bankmoney>0"); } else { $db->query("UPDATE users SET bankmoney=bankmoney+(bankmoney*0.05) where bankmoney>0"); } Instead of giving 1mil to people with over 20mil in bank, it gives the normal 5%. Its really confusing as it works on testing server account. The only difference I know is that on testing server account I run the cron manually to test it whereas on the actual sites its an automatic cron. Please help someone. Quote
CrazyT Posted August 16, 2009 Posted August 16, 2009 Re: Max Bank Interest :O Selecting everythink from users? :O, you only need to grab one thing.. $is = $db->fetch_row($db->query('SELECT bankmoney FROM users;')); Quote
Haunted Dawg Posted August 16, 2009 Posted August 16, 2009 Re: Max Bank Interest And you would need a while() function. Thus i suggest you use my method :P Quote
Adil Posted August 16, 2009 Author Posted August 16, 2009 Re: Max Bank Interest I used yours and that doesnt work either. Quote
wolfe Posted August 16, 2009 Posted August 16, 2009 Re: Max Bank Interest Update users set bankmoney = bankmoney + (bankmoney * .05) where bankmoney > 0 && bankmoney < 20000000 update users set bankmoney = bankmoney + 1000000 where bankmoney >= 20000000 HD's method should work as well. Less queries that way. Quote
Adil Posted August 16, 2009 Author Posted August 16, 2009 Re: Max Bank Interest wolfe thanks a lot no idea why I didnt think of that! Thanks HD's didnt work unless I pasted it wrong Quote
Lithium Posted August 17, 2009 Posted August 17, 2009 Re: Max Bank Interest mysql_query('UPDATE `users` SET `bankmoney` = `bankmoney` + (IF((`bankmoney` * 0.05) > 90000000), 90000000, (`bankmoney` * 0.05))) WHERE `bankmoney` > 0'); Should work mysql_query("UPDATE `bankmoney` SET `users`.`bankmoney` = `users`.`bankmoney` + IF( `users`.`bankmoney` * 0.05 < 1000000, ((`users`.`bankmoney` * 0.10)), 1000000 ) WHERE `users`.`bankmoney` > '0'") just to fix a minor mistake on HD's post ;) Quote
KyleMassacre Posted January 24, 2012 Posted January 24, 2012 how would i make it to where they keep getting interest daily but the interest is say 8% no matter if they have $1 or $20 million? Quote
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.