Add and Subtract
| From: | Jennifer Downey | Date: | Sat, 23 Feb 2002 07:35:12 +0000 |
| Subject: | Add and Subtract | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-17216@lists.php.net to get a copy of this message | ||
Hi All,
Would someone please help me with the following code?
I am trying to make this work like if I have 15 gold pieces and I deposit 5
it will subtract 5 from the gold pieces I have and deposit the 5 into my
account
showing that I now have 10 gold pieces I can deposit and 5 in the bank.
I would really appreciate any help.
Thanks in advance.
Jen Downey
<BR><BR><BR>
<FORM ACTION="bank.php" METHOD="POST" TITLE="bank">
<TABLE BORDER="0" WIDTH="25%" CELLPADDING="0"
CELLSPACING="0">
<TR>
<TD><font size="2">Deposit</font></TD>
<TD> <INPUT TYPE="text" VALUE=""
NAME="user_deposit"></TD>
</TR>
<TR>
<TD></TD>
<TD><INPUT TYPE="submit" VALUE="Make My Deposit"
NAME="deposit"></TD>
</TR>
</TABLE>
<BR><BR><BR><BR><BR><BR>
<? $query="SELECT bank_points FROM wt_users WHERE uid={$session["uid"]}";
$ret = mysql_query($query);
while(list($points)=
mysql_fetch_row($ret))
print("<BR><BR><BR>You have $points Gold Pieces you may withdraw!");
?>
<BR><BR><BR>
<TABLE BORDER="0" WIDTH="25%" CELLPADDING="0"
CELLSPACING="0">
<TR>
<TD><font size="2">Withdraw</font></TD>
<TD> <INPUT TYPE="text" VALUE=""
NAME="user_withdraw"></TD>
</TR>
<TR>
<TD></TD>
<TD><INPUT TYPE="submit" VALUE="Make My Withdraw"
NAME="withdraw"></TD>
</TR>
</TABLE>
</FORM>
<?
$db["bank_points"]=("UPDATE wt_users set bank_points = bank_points +
$user_deposit");
$result=mysql_query($db["bank_points"]);
$db["bank_points"]=("UPDATE wt_users set bank_points = bank_points -
$user_withdraw");
$result=mysql_query($db["bank_points"]);