<?php
include("db.php");
$old = $_POST['old'];
$new = $_POST['new'];
$id = $_POST['id'];

$txt = "select * from `member`  where `member`.`id_member` = '$new'";
$query =mysqli_query($db,$txt);
$row = mysqli_fetch_assoc($query);
$new_mony = $row['price_game'];
$count_game = $row['count_game'];
if($row['type_member'] == 0)
{
    $txt = "select * from `member` where `id_member` = '$old'";
    $query =mysqli_query($db,$txt);
    $row = mysqli_fetch_assoc($query);
    $old_mony = $row['price_game'];
    $txt = "update `cus` set `id_member` = '"+$new+"' ,`count_s` = '$count_game', `mony_cus` = 0 where `id_cus` = '"+$id+"'";
    $query = mysqli_query($db,$txt);
}
if($row['type_member'] == 1)
{
    $txt = "select * from `member` where `id_member` = '$old'";
    $query =mysqli_query($db,$txt);
    $row = mysqli_fetch_assoc($query);
    $old_mony = $row['price_game'];
    $txt = "update `cus` set `id_member` = '"+$new+"' , `mony_cus` = 0 where `id_cus` = '"+$id+"'";
    $query = mysqli_query($db,$txt);
}
if($row['type_member'] == 2)
{
    $txt = "select * from `member` where `id_member` = '$old'";
    $query =mysqli_query($db,$txt);
    $row = mysqli_fetch_assoc($query);
    $old_mony = $row['price_game'];
    $txt = "update `cus` set `id_member` = '"+$new+"' ,`count_s` = '$count_game', `mony_cus` = 0 where `id_cus` = '"+$id+"'";
    $query = mysqli_query($db,$txt);
}
$data['a'] = 0;
echo json_encode($data);
?>