I am building a site where users can transfer funds to one another.
I have my code working so each user can send funds, however i'm not sure how to only let them transfer what they have.. (if they have 10 cant send 11)
See code below
$result = mysql_query("UPDATE member
SET balance = IF(personID = $accountfrom, balance-$amount, balance+$amount)
WHERE personID IN ($accountfrom, $accountto)")
or die(mysql_error());
Can anyone help with this??
UPDATED
$select_result = $mysqli->query("SELECT * FROM member where personID="$accountfrom" ");
while ($select = mysqli_fetch_assoc($select_result)) {
$balance=$select['amount'];
if($balance=>$balance){
$result = mysql_query("UPDATE member
SET balance = IF(personID = $accountfrom, balance-$amount, balance+$amount)
WHERE personID IN ($accountfrom, $accountto)")
or die(mysql_error());
}
}
Shows error:
Parse error: syntax error, unexpected T_VARIABLE in >/home/u704855438/public_html/transfer.php on line 264
Line 266 is if($balance=>$amount){