ı want to update my session variable this code:
if (isset($_POST['topla'])) {
$kazanc_cow = $_SESSION['cow'] * "0.003";
$kazanc_chicken = $_SESSION['chicken'] * "0.001";
$db_kazanc = $_SESSION['kazanc'];
$toplam_kazanc = $db_kazanc + $kazanc_chicken + $kazanc_cow;
$uid = $_SESSION['user_id'];
$sql = "UPDATE users SET kazanc='$toplam_kazanc' WHERE id='$uid'";
if ($con->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
I am get variable from my database $_SESSION['kazanc'] = $row["kazanc"];
using mysqli_fetch_array
method. how ı update my session kazanc variable from database?