<?
$q=mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` != '0' ORDER BY `time` DESC");
$theli=0;
while($post=mysql_fetch_array($q))
{
$ttheli=500;
if($post['heli']==3)$ttheli=1000;
if($post['heli']==4)$ttheli=3000;
$theli=$theli+$ttheli;
}
$meh_all=0;
$arena_rate=0;

$q=mysql_query("SELECT * FROM `kolhoz_collective_user` WHERE `id_collective` = '$mc[id]'");
while($post=mysql_fetch_array($q))
{
$usk=mysql_fetch_array(mysql_query("SELECT `tehnika`,`arena_rating` FROM `kolhoz_user` WHERE `id` = '$post[id_user]'"));
$meh_all=$meh_all+$usk['tehnika'];
$arena_rate=$arena_rate+$usk['arena_rating'];
}
if($meh_all>$mc['tehnika'])mysql_query("UPDATE `kolhoz_collective` SET `tehnika` = '$meh_all' WHERE `id` = '$mc[id]'");
if($arena_rate>$mc['arena_rate'])mysql_query("UPDATE `kolhoz_collective` SET `arena_rate` = '$arena_rate' WHERE `id` = '$mc[id]'");
?>