Hello I am trying to subtract the accepted bid which is an int from the job table and subtract from the credit from customer table but for some reason it updatedes credit row as -21 rather than 78 as accepted bid is =22. Any ideas why this is?
tables: https://i.stack.imgur.com/3bjbe.jpg
<?php
session_start();
require 'config.php';
$id = $_SESSION['login_user'];
$jobid = $_POST['job_id'];
$poster_id = $_POST['poster_id'];
$accepted_bidder = $_POST['accepted_bidder'];
$accepted_bid = (int) $_POST['accepted_bid'];
$query = "SELECT credit FROM `customer` WHERE email_adress = '$id'";
$result = $conn->query($query);
//echo $result;
//echo $accepted_bid;
$updated_credit = (int)$result- $accepted_bid;
//echo $updated_credit;
$query2 = "UPDATE job SET start_escrow = '1' WHERE job_id = '$jobid'";
$success = $conn->query($query2);
$query3 = " UPDATE customer SET credit = '$updated_credit' WHERE email_adress = '$id'";
$success3 = $conn->query($query3);
$poster_id = $_POST['poster_id'];
if (!$success) {
die("Couldn't enter data: ".$conn->error);
}
header("location: myjobs.php");
echo "Thank You For Contacting Us <br>";
$conn->close();
?>