<?
$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;
$rating_gos_all=0;
if(isset($_GET['collectives']) OR isset($_GET['mycollective'])){
$q=mysql_query("SELECT * FROM `kolhoz_collective_user` WHERE `id_user` = '$ku[id]'");
$post=mysql_fetch_array($q);
if($post['day']!==date("d", time()) AND date("D", time())=='Mon')mysql_query("UPDATE `kolhoz_collective_user` SET `day` = '".date('d', time())."',`rating_week`='0',`rubies_week`='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 * FROM `kolhoz_user` WHERE `id` = '$post[id_user]'"));
$meh_all=$meh_all+$usk['tehnika'];
}
if($meh_all>$mc['tehnika'])mysql_query("UPDATE `kolhoz_collective` SET `tehnika` = '$meh_all' WHERE `id` = '$mc[id]'");

}
?>