<?
$rew1 = qw("SELECT COUNT(*) FROM voyna WHERE strana='$re1[strana]'");
$row = mysql_fetch_row($rew1);{$total1 = $row[0];}
if($total1>0){
$money = qw("SELECT * FROM voyna  WHERE strana='$re1[strana]'");
while($array = mysql_fetch_array($money)){
$rew2 = mysql_fetch_array(qw("SELECT id FROM gos WHERE strana='$array[vrag]'"));
$total=$rew2['id'];
if($total >0){}else{
$res=mysql_fetch_array(qw("SELECT * FROM voyna WHERE strana='$re1[strana]' AND vrag='$array[vrag]'"));
$peh=$res['peh'];$kaz=$res['kon'];$gva=$res['str'];
$puh=$res['puh'];$tan=$res['tan'];$sam=$res['sam'];
qw("UPDATE gos2 SET peh=peh+$peh,kon=kon+$kaz,str=str+$gva,puh=puh+$puh,tan=tan+$tan,sam=sam+$sam WHERE strana='$re1[strana]'");
qw("DELETE FROM voyna WHERE id='$array[id]'");$tm=time();
qw("INSERT INTO mess (komu,kto,data,st,tip,text) VALUES('$re1[strana]','@','$tm','0','0','Гос-во $array[vrag] проиграло,войска вернулись домой!')");
header("Location:game.php?der=$key");
}
}
}
?>