我遇到了问题,我不知道如何解决它。
当交易进入负数或正数时,我有一个表从soll(负数)变为haben(正数)。
例: A队:'pes_teams_budget'= 5,'pes_teams_konto'= haben B队:'pes_teams_budget'= -5(手动改变以调整预算),'pes_teams_konto'= soll
A队向B队支付10欧元。
结果是: A队:'pes_teams_budget'= 5,'pes_teams_konto'= soll B队:'pes_teams_budget'= 5,'pes_teams_konto'= haben
它应该是: A队:'pes_teams_budget'= * - * 5 ,'pes_teams_konto'= soll B队:'pes_teams_budget'= 5,'pes_teams_konto'= haben
守则不会改变/显示负值。它只是保持正数,但从soll变为haben。
接下来的问题:看到这仍然是一个正数,它不再正常计算。
我希望有人可以帮助我,如果需要进一步的信息让我知道。谢谢
$receiver_data = get_team_data($receiver);
$receiver_budget = (int)$receiver_data['pes_teams_budget'];
$receiver_sql = "";
if($receiver_data['pes_teams_konto'] == "soll") {
if( $receiver_budget < $ammount ) {
$positiv_rest = $ammount - $receiver_budget;
$disposer_sql = "UPDATE `d017ee3d`.`pes_teams` SET `pes_teams_konto` = 'haben', `pes_teams_budget` = '".(string)$positiv_rest."' WHERE `pes_teams`.`pes_teams_ID` =".$receiver.";";
} elseif($receiver_budget == $ammount ) {
$receiver_sql = "UPDATE `d017ee3d`.`pes_teams` SET `pes_teams_konto` = 'haben', `pes_teams_budget` = '0' WHERE `pes_teams`.`pes_teams_ID` =".$receiver.";";
} else {
$receiver_sql = "UPDATE `d017ee3d`.`pes_teams` SET `pes_teams_budget` = `pes_teams_budget` - '".$ammount_param."' WHERE `pes_teams`.`pes_teams_ID` =".$receiver.";";
}
} else {
$receiver_sql = "UPDATE `d017ee3d`.`pes_teams` SET `pes_teams_budget` = `pes_teams_budget` + '".$ammount_param."' WHERE `pes_teams`.`pes_teams_ID` =".$receiver.";";
}
$return['receiver_sql'] = $receiver_sql;
include('dbconnect.php');
$receiver_result = mysql_query($receiver_sql);
$return['receiver_result'] = $receiver_result;
if (!$receiver_result) {
$return['error_receiver'] .= 'Ungültige Anfrage: '.mysql_error();
} else {
$return['status_receiver'] = "success";
}
//UPDATE mytab SET geld = geld - '200' WHERE id = $disposer
//UPDATE mytab SET geld = geld - '200' WHERE id = $receiver
//UPDATE `d017ee3d`.`pes_teams` SET `pes_teams_budget` = '100000001' WHERE `pes_teams`.`pes_teams_ID` =1;
//UPDATE `d017ee3d`.`pes_teams` SET `pes_teams_konto` = 'soll', `pes_teams_budget` = '1000' WHERE `pes_teams`.`pes_teams_ID` =1;
return $return;