<?
if(isset($_GET['level2']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_zavod` WHERE `id` = '".intval($_GET['level2'])."' AND `id_user` = '$ku[id]' AND `id_pet` != '0' AND `level` < '20'"),0)!=0)
{
$zavod=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_zavod` WHERE `id` = '".intval($_GET['level2'])."' AND `id_user` = '$ku[id]' AND `id_pet` != '0' AND `level` < '20'"));
$zavod['next_level']=$zavod['level']+1;
$money_level=$zavod['next_level']*1000;
if($ku['money']>=$money_level)
{
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']-$money_level)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_zavod` SET `level` = '$zavod[next_level]' WHERE `id` = '$zavod[id]'");
}
else $_SESSION['no_money']=$ku['money']-$money_level;
header("Location:?myzavod&moderate&".passgen());
exit;
}
?>