Dan13071992
01-11-2012, 04:56 PM
hi guys, ive got a function where you earn intrest every 24 hours on money you put in the bank, however even with my makecomma function it still produces decimale places, which i dont want it to, could anyone help please?
if (time() <= $fetch->banktime){
$intrestsum = $fetch->bank / 100 * 6;
$newnewmoney = $fetch->bank + $intrestsum;
mysql_query("UPDATE users SET bank='$newnewmoney' WHERE username='$fetch->username'");
$sendmessage= "
<b>Federal Bank</b>
<br>
Your bank account has matured!
<br><br>
Previous balance: $".makecomma($fetch->bankold)."<br>
Interest earned: $".makecomma($intrestsum)."<br>
Current balance: $".makecomma($newnewmoney)."<br>
<br>
Visit the <b>Federal Bank</b> to withdraw or renew your balance.
";
mysql_query("INSERT INTO `inbox` (`id`, `to`, `from`, `message`, `date`, `read`) VALUES ('', '".dbSafe($fetch->username)."', '".dbSafe($fetch->username)."', '".dbSafe($sendmessage)."', '".dbSafe($date)."', '0');") or die (mysql_error());
}
the make comma function is:
function makecomma($input)
{
if(strlen($input)<=3)
{ return $input; }
$length=substr($input,0,strlen($input)-3);
$formatted_input = makecomma($length).",".substr($input,-3);
return $formatted_input;
}
and the message i get in inbox is this:
Federal Bank
Your bank account has matured!
Previous balance: $4,000,007
Interest earned: $442,819,.26
Current balance: $7,823,140,.26
Visit the Federal Bank to withdraw or renew your balance.
can you see how the first one comes out normally, thats because its in the database, however the other two are posted from the page if the time is >=
$fetch->banktime (in the code its <= as for testing purposes, but they come out with the decimal place,, but it doesnt put the decimal place into the database, which is good but it still displays as a decimal.
any help would be great.
if (time() <= $fetch->banktime){
$intrestsum = $fetch->bank / 100 * 6;
$newnewmoney = $fetch->bank + $intrestsum;
mysql_query("UPDATE users SET bank='$newnewmoney' WHERE username='$fetch->username'");
$sendmessage= "
<b>Federal Bank</b>
<br>
Your bank account has matured!
<br><br>
Previous balance: $".makecomma($fetch->bankold)."<br>
Interest earned: $".makecomma($intrestsum)."<br>
Current balance: $".makecomma($newnewmoney)."<br>
<br>
Visit the <b>Federal Bank</b> to withdraw or renew your balance.
";
mysql_query("INSERT INTO `inbox` (`id`, `to`, `from`, `message`, `date`, `read`) VALUES ('', '".dbSafe($fetch->username)."', '".dbSafe($fetch->username)."', '".dbSafe($sendmessage)."', '".dbSafe($date)."', '0');") or die (mysql_error());
}
the make comma function is:
function makecomma($input)
{
if(strlen($input)<=3)
{ return $input; }
$length=substr($input,0,strlen($input)-3);
$formatted_input = makecomma($length).",".substr($input,-3);
return $formatted_input;
}
and the message i get in inbox is this:
Federal Bank
Your bank account has matured!
Previous balance: $4,000,007
Interest earned: $442,819,.26
Current balance: $7,823,140,.26
Visit the Federal Bank to withdraw or renew your balance.
can you see how the first one comes out normally, thats because its in the database, however the other two are posted from the page if the time is >=
$fetch->banktime (in the code its <= as for testing purposes, but they come out with the decimal place,, but it doesnt put the decimal place into the database, which is good but it still displays as a decimal.
any help would be great.