I have a table in my database called member
within this table are the fields 'personID&
balance`.
If a user 1 has a balance of 20.00 and wishes to send 10.00 to user 2 what is the best way to reduce user 1's balance and update user 2's balance?
Any help/advice would be great!
Thanks in advance
UPDATE
CODE:
$accountfrom=$_POST[accountfrom];
$accountto=$_POST[accountto];
$amount=$_POST[amount];
$con = mysql_connect("localhost","cl49-XXX","XXX");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("cl49-XXX", $con)or die( "Unable to select database");
$result = mysql_query("UPDATE member
SET balance = IF(personID = $acountfrom, balance-$amount, balance+$amount)
WHERE personID IN ($accountfrom, $accountto)")
or die(mysql_error());
RESULT:
'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' balance-100.00, balance+100.00) WHERE personID IN (84587745 , 98554130)' at line 2'