Jump to content

[SOLVED] Interest Script Problems


Monk3h

Recommended Posts

I have a problem with my interest script. every player has a bank account in my game, there bank account name and interest rates are stoped in the players table. The interest is given out in the reset script which controlls all the resets for my game. I am having a problem with giving the players there individual rates of interest. The code i am using at the moment does not work which isnt suprising as its a shot in the dark. Im really stuck here.. How would i give each player there interest thru my reset script?

 

 

This is the script im using so far to give you an idea of what im tying to do.

 

$bank = mysql_fetch_array(mysql_query("select * from players")); 
$int = ($bank[bank] / 100);
$interest = ($int * $bank[interest]);
mysql_query("update players set bank=bank+$interest");

Link to comment
https://forums.phpfreaks.com/topic/103091-solved-interest-script-problems/
Share on other sites

<?php
$resultsBank = mysql_query("select * from players");
while($bank = mysql_fetch_array($resultsBank)){ 
     $int = $bank['bank'] / 100;
     $interest = $int * $bank['interest'];
     $total = $bank['bank'] + $interest;
     $userID = $bank['id'];
     mysql_query("UPDATE players SET bank='$total' WHERE id=$userID");
}
?>

 

I made several adjustements so look it carefully. It should work now.

and....

<?php
//attempting to get 8.5% interest
$money = "100";
$interest = ".085";
$interest2 = $money * $interest;
print $interest2;

a modification of your script that works. use this for math (if that's your issue). GuiltyGears should work, but I had already written it.......

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.