Well, I made an achievement system for my game. I have an achievement for banking a certain amount. Well, when their's the certain amount banked you will have the achievement posted on your users wall. But when you withdraw cash the achievement will go away. Here's the coding below. So how could I fix it to where the achievement will stay even after the cash is gone from the users bank account?
<?php
if ( $userp['bank_account'] >= 100000 )
{
echo
'<img src="achievements/Diamond-Bank.png" hspace="5" width="65" height="65" title="Diamond Banker: Made a deposit of $100,000 or more!"">';
}
elseif ( $userp['bank_account'] >= 50000 )
{
echo
'<img src="achievements/Gold-Bank.png" hspace="5" width="65" height="65" title="Golden Banker: Made a deposit of $50,000 of more."">';
}
elseif ( $userp['bank_account'] >= 1000 )
{
echo
'<img src="achievements/Silver-Bank.png" hspace="5" width="65" height="65" title="Silver Banker: Made a deposit of $1,000 or more."">';
}
elseif ( $userp['bank_account'] >= 1 )
{
echo
'<img src="achievements/Bronze-Bank.png" hspace="5" width="65" height="65" title="Bronze Banker: Opened a bank account!"">';
}
?>
I would do it by adding 1 more column to the mysql
table - achievement
with DEFAULT = 0
. Then add the achievement
badge using your criteria -
<?php
if ( $userp['bank_account'] >= 100000 )
{
"UPDATE table SET `achievement` = 4"
}
elseif ( $userp['bank_account'] >= 50000 )
{
"UPDATE table SET `achievement` = 3";
}
elseif ( $userp['bank_account'] >= 1000 )
{
"UPDATE table SET `achievement` = 2";
}
elseif ( $userp['bank_account'] >= 1 )
{
"UPDATE table SET `achievement` = 1";
}
?>
And then to view the achievement
badge -
<?php
if ( $userp['achievement'] = 4 )
{
echo
'<img src="achievements/Diamond-Bank.png" hspace="5" width="65" height="65" title="Diamond Banker: Made a deposit of $100,000 or more!"">';
}
elseif ( $userp['achievement'] = 3 )
{
echo
'<img src="achievements/Gold-Bank.png" hspace="5" width="65" height="65" title="Golden Banker: Made a deposit of $50,000 of more."">';
}
elseif ( $userp['achievement'] = 2 )
{
echo
'<img src="achievements/Silver-Bank.png" hspace="5" width="65" height="65" title="Silver Banker: Made a deposit of $1,000 or more."">';
}
elseif ( $userp['achievement'] = 1 )
{
echo
'<img src="achievements/Bronze-Bank.png" hspace="5" width="65" height="65" title="Bronze Banker: Opened a bank account!"">';
}
?>