<?php
if($user['fermer_oput']>=0 && $user['fermer_oput']<=150)$level=0;
elseif($user['fermer_oput']>=151 && $user['fermer_oput']<=300)$level=1;
elseif($user['fermer_oput']>=301 && $user['fermer_oput']<=800)$level=2;
elseif($user['fermer_oput']>=801 && $user['fermer_oput']<=1300)$level=3;
elseif($user['fermer_oput']>=1301 && $user['fermer_oput']<=2000)$level=4;
elseif($user['fermer_oput']>=2001 && $user['fermer_oput']<=3000)$level=5;
elseif($user['fermer_oput']>=3001 && $user['fermer_oput']<=4500)$level=6;
elseif($user['fermer_oput']>=4501 && $user['fermer_oput']<=6000)$level=7;
elseif($user['fermer_oput']>=6001 && $user['fermer_oput']<=9000)$level=8;
elseif($user['fermer_oput']>=9001 && $user['fermer_oput']<=12000)$level=9;
elseif($user['fermer_oput']>=12001 && $user['fermer_oput']<=16000)$level=10;
elseif($user['fermer_oput']>=16001 && $user['fermer_oput']<=20000)$level=11;
elseif($user['fermer_oput']>=20001 && $user['fermer_oput']<=25000)$level=12;
elseif($user['fermer_oput']>=25001 && $user['fermer_oput']<=30000)$level=13;
elseif($user['fermer_oput']>=30001 && $user['fermer_oput']<=35000)$level=14;
elseif($user['fermer_oput']>=35001 && $user['fermer_oput']<=40000)$level=15;
elseif($user['fermer_oput']>=40001 && $user['fermer_oput']<=50000)$level=16;
elseif($user['fermer_oput']>=50001 && $user['fermer_oput']<=60000)$level=17;
elseif($user['fermer_oput']>=60001 && $user['fermer_oput']<=70000)$level=18;
elseif($user['fermer_oput']>=70001 && $user['fermer_oput']<=85000)$level=19;
elseif($user['fermer_oput']>=85001 && $user['fermer_oput']<=90000)$level=20;
elseif($user['fermer_oput']>=90001 && $user['fermer_oput']<=105000)$level=21;
elseif($user['fermer_oput']>=105001 && $user['fermer_oput']<=115000)$level=22;
elseif($user['fermer_oput']>=115001 && $user['fermer_oput']<=130000)$level=23;
elseif($user['fermer_oput']>=130001 && $user['fermer_oput']<=155000)$level=24;
elseif($user['fermer_oput']>=155001 && $user['fermer_oput']<=170000)$level=25;
elseif($user['fermer_oput']>=170001 && $user['fermer_oput']<=190000)$level=26;
elseif($user['fermer_oput']>=190001 && $user['fermer_oput']<=210000)$level=27;
elseif($user['fermer_oput']>=210001 && $user['fermer_oput']<=230000)$level=28;
elseif($user['fermer_oput']>=230001 && $user['fermer_oput']<=250000)$level=29;
elseif($user['fermer_oput']>=250001 && $user['fermer_oput']<=270000)$level=30;
elseif($user['fermer_oput']>=270001 && $user['fermer_oput']<=290000)$level=31;
elseif($user['fermer_oput']>=290001 && $user['fermer_oput']<=320000)$level=32;
elseif($user['fermer_oput']>=320001 && $user['fermer_oput']<=340000)$level=33;
elseif($user['fermer_oput']>=340001 && $user['fermer_oput']<=360000)$level=34;
elseif($user['fermer_oput']>=360001 && $user['fermer_oput']<=400000)$level=35;
elseif($user['fermer_oput']>=400001 && $user['fermer_oput']<=450000)$level=36;
elseif($user['fermer_oput']>=450001 && $user['fermer_oput']<=500000)$level=37;
elseif($user['fermer_oput']>=500001 && $user['fermer_oput']<=550000)$level=38;
elseif($user['fermer_oput']>=550001 && $user['fermer_oput']<=600000)$level=39;
elseif($user['fermer_oput']>=600001 && $user['fermer_oput']<=650000)$level=40;
elseif($user['fermer_oput']>=650001 && $user['fermer_oput']<=700000)$level=41;
elseif($user['fermer_oput']>=700001 && $user['fermer_oput']<=750000)$level=42;
elseif($user['fermer_oput']>=750001 && $user['fermer_oput']<=800000)$level=43;
elseif($user['fermer_oput']>=800001 && $user['fermer_oput']<=850000)$level=44;
elseif($user['fermer_oput']>=850001 && $user['fermer_oput']<=900000)$level=45;
elseif($user['fermer_oput']>=950001 && $user['fermer_oput']<=1000000)$level=46;
elseif($user['fermer_oput']>=1000001 && $user['fermer_oput']<=1100000)$level=47;
elseif($user['fermer_oput']>=1100001 && $user['fermer_oput']<=1200000)$level=48;
elseif($user['fermer_oput']>=1200001 && $user['fermer_oput']<=1300000)$level=49;
elseif($user['fermer_oput']>=1300001 && $user['fermer_oput']<=1400000)$level=50;
elseif($user['fermer_oput']>=1400001 && $user['fermer_oput']<=1500000)$level=51;
elseif($user['fermer_oput']>=1500001 && $user['fermer_oput']<=1600000)$level=52;
elseif($user['fermer_oput']>=1600001 && $user['fermer_oput']<=1700000)$level=53;
elseif($user['fermer_oput']>=1700001 && $user['fermer_oput']<=1800000)$level=54;
elseif($user['fermer_oput']>=1800001 && $user['fermer_oput']<=1900000)$level=55;
elseif($user['fermer_oput']>=1900001 && $user['fermer_oput']<=2000000)$level=56;
elseif($user['fermer_oput']>=2000001 && $user['fermer_oput']<=2200000)$level=57;
elseif($user['fermer_oput']>=2200001 && $user['fermer_oput']<=2400000)$level=58;
elseif($user['fermer_oput']>=2400001 && $user['fermer_oput']<=2600000)$level=59;
elseif($user['fermer_oput']>=2600001 && $user['fermer_oput']<=2800000)$level=60;
elseif($user['fermer_oput']>=2800001 && $user['fermer_oput']<=3000000)$level=61;
elseif($user['fermer_oput']>=3000001 && $user['fermer_oput']<=3300000)$level=62;
elseif($user['fermer_oput']>=3300001 && $user['fermer_oput']<=3600000)$level=63;
elseif($user['fermer_oput']>=3600001 && $user['fermer_oput']<=3900000)$level=64;
elseif($user['fermer_oput']>=3900001 && $user['fermer_oput']<=4300000)$level=65;
elseif($user['fermer_oput']>=4300001 && $user['fermer_oput']<=4600000)$level=66;
elseif($user['fermer_oput']>=4600001 && $user['fermer_oput']<=4900000)$level=67;
elseif($user['fermer_oput']>=4900001 && $user['fermer_oput']<=5200000)$level=68;
elseif($user['fermer_oput']>=5200001 && $user['fermer_oput']<=5500000)$level=69;
elseif($user['fermer_oput']>=5500001 && $user['fermer_oput']<=5800000)$level=70;
elseif($user['fermer_oput']>=5800001 && $user['fermer_oput']<=6100000)$level=71;
elseif($user['fermer_oput']>=6100001 && $user['fermer_oput']<=6300000)$level=72;
elseif($user['fermer_oput']>=6300001 && $user['fermer_oput']<=6700000)$level=73;
elseif($user['fermer_oput']>=6700001 && $user['fermer_oput']<=7100000)$level=74;
elseif($user['fermer_oput']>=7100001 && $user['fermer_oput']<=7400000)$level=75;
elseif($user['fermer_oput']>=7400001 && $user['fermer_oput']<=7800000)$level=76;
elseif($user['fermer_oput']>=7800001 && $user['fermer_oput']<=8200000)$level=77;
elseif($user['fermer_oput']>=8200001 && $user['fermer_oput']<=8600000)$level=78;
elseif($user['fermer_oput']>=8600001 && $user['fermer_oput']<=9000000)$level=79;
elseif($user['fermer_oput']>=9000001 && $user['fermer_oput']<=9500000)$level=80;
elseif($user['fermer_oput']>=9500001 && $user['fermer_oput']<=10000000)$level=81;
elseif($user['fermer_oput']>=10000001 && $user['fermer_oput']<=10500000)$level=82;
elseif($user['fermer_oput']>=10500001 && $user['fermer_oput']<=11000000)$level=83;
elseif($user['fermer_oput']>=11000001 && $user['fermer_oput']<=11500000)$level=84;
elseif($user['fermer_oput']>=11500001 && $user['fermer_oput']<=12000000)$level=85;
elseif($user['fermer_oput']>=12000001 && $user['fermer_oput']<=12500000)$level=86;
elseif($user['fermer_oput']>=12500001 && $user['fermer_oput']<=13000000)$level=87;
elseif($user['fermer_oput']>=13000001 && $user['fermer_oput']<=13500000)$level=88;
elseif($user['fermer_oput']>=13500001 && $user['fermer_oput']<=14000000)$level=89;
elseif($user['fermer_oput']>=14000001 && $user['fermer_oput']<=14500000)$level=90;
elseif($user['fermer_oput']>=14500001 && $user['fermer_oput']<=15000000)$level=91;
elseif($user['fermer_oput']>=15000001 && $user['fermer_oput']<=16000000)$level=92;
elseif($user['fermer_oput']>=16000001 && $user['fermer_oput']<=17000000)$level=93;
elseif($user['fermer_oput']>=17000001 && $user['fermer_oput']<=18000000)$level=94;
elseif($user['fermer_oput']>=18000001 && $user['fermer_oput']<=19000000)$level=95;
elseif($user['fermer_oput']>=19000001 && $user['fermer_oput']<=20000000)$level=96;
elseif($user['fermer_oput']>=20000001 && $user['fermer_oput']<=21000000)$level=97;
elseif($user['fermer_oput']>=21000001 && $user['fermer_oput']<=22000000)$level=98;
elseif($user['fermer_oput']>=22000001 && $user['fermer_oput']<=23000000)$level=99;
elseif($user['fermer_oput']>=23000001 && $user['fermer_oput']<=220000000)$level=100;

if($user['fermer_level']!=$level)mysql_query("UPDATE `user` SET `fermer_level` = '".$level."' WHERE `id` = $user[id] LIMIT 1");

echo "<img src='gold.gif'>: <b>$user[fermer_money]</b> ";
echo "<img src='level.gif'>: <b>".$level."</b> <br/>";
echo "<img src='users.png'>: <b>$user[fermer_oput]</b> ";
echo " "; 
$i=mysql_query("SELECT * FROM `fermer_gr` WHERE `kol` = '0'");
while($ii=mysql_fetch_array($i)){
$semenk=mysql_fetch_array(mysql_query("SELECT *
FROM `fermer_name` WHERE `id` = '$ii[semen]' LIMIT 1"));

$pt=rand($semenk['rand1'],$semenk['rand2']); 
if($ii['woter']==0)$pt=floor($pt/2);

mysql_query("UPDATE `fermer_gr` SET `kol` = $pt WHERE `id` = '$ii[id]' LIMIT 1");
 }

?>