Jump to content
MakeWebGames

Max Bank Interest


Adil

Recommended Posts

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?

Link to comment
Share on other sites

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%.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...