Monk3h Posted April 27, 2008 Share Posted April 27, 2008 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 More sharing options...
Fadion Posted April 27, 2008 Share Posted April 27, 2008 <?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. Link to comment https://forums.phpfreaks.com/topic/103091-solved-interest-script-problems/#findComment-528073 Share on other sites More sharing options...
jonsjava Posted April 27, 2008 Share Posted April 27, 2008 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....... Link to comment https://forums.phpfreaks.com/topic/103091-solved-interest-script-problems/#findComment-528074 Share on other sites More sharing options...
Monk3h Posted April 27, 2008 Author Share Posted April 27, 2008 Thank you both for your help! I used the first Script posted after looking it over as Advised. It works Perfectly! Your both Life savers! <3 Link to comment https://forums.phpfreaks.com/topic/103091-solved-interest-script-problems/#findComment-528085 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.