Is this right way to perform the subtraction operation in case of prepared statement in the sql query ?
$sql = "UPDATE users set credits = (credits-$price) WHERE username = ?";
Code to subtracted the user credits based on the value of $price
$price = $row0['price'];
$sql = "UPDATE users set credits = (credits-$price) WHERE username = ?;";
$stmt1 = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt1, $sql)) {
$db_err = array("error" => "Database");
echo json_encode($db_err);
} else {
mysqli_stmt_bind_param($stmt1, "s", $_SESSION['username']);
mysqli_stmt_execute($stmt1);