I’m trying to build a custom function on my website i’m trying to build a custom gift function i want users to buy coins and add them to a database but i’m have trouble selecting if the coin amount is in the database i don’t know how to select like this so lets say i have 200 coins in the database but i want to send i gift that is 100 coins how do i select 100 from 200 amount in the database or i’m i doing it wrong any help.
[php]$stmt = $isv_db->prepare(“SELECT coin_total - $this->coin_total = $this->coin_total FROM users_coins WHERE $this->coin_total=? AND user_id=?”);
$stmt->bind_param(‘i’, $user);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($coin_total);
$stmt->fetch();
if ($stmt->num_rows() < 1){
$stmt->close();
$array[‘err’] = true;
$array[‘message’] = ‘You need more coins’;
echo json_encode($array);
exit();
}[/php]