<?
$sot_db_host = 'localhost'; // хост
$sot_db_user_name = 'valfe201_ferma'; // имя пользователя
$sot_db_password = 'paifeM9dohbid1o'; // пароль
$sot_db_name = 'valfe201_ferma'; // имя базы данных

if(!($db=@mysql_connect($sot_db_host, $sot_db_user_name, $sot_db_password))){
header("Location:/404.php");
exit;
}

if (!@mysql_select_db($sot_db_name,$db)){
echo "Wrong MySQL db name";
exit;
}

mysql_query('set charset utf8',$db); 
mysql_query('SET names utf8',$db); 
mysql_query('set character_set_client="utf8"',$db); 
mysql_query('set character_set_connection="utf8"',$db); 
mysql_query('set character_set_result="utf8"',$db);

#======================================

function num_acc($num){
if($num <= 1000){$rez = 1;}
elseif($num <= 2000){$rez = 2;}
elseif($num <= 3000){$rez = 3;}
elseif($num <= 4000){$rez = 4;}
elseif($num <= 5000){$rez = 5;}
elseif($num <= 6000){$rez = 6;}
elseif($num <= 7000){$rez = 7;}
elseif($num <= 8000){$rez = 8;}
elseif($num <= 9000){$rez = 9;}
elseif($num <= 10000){$rez = 10;}
elseif($num <= 11000){$rez = 11;}
elseif($num <= 12000){$rez = 12;}
elseif($num <= 13000){$rez = 13;}
elseif($num <= 14000){$rez = 14;}
elseif($num <= 15000){$rez = 15;}
elseif($num <= 16000){$rez = 16;}
elseif($num <= 17000){$rez = 17;}
elseif($num <= 18000){$rez = 18;}
elseif($num <= 19000){$rez = 19;}
elseif($num <= 20000){$rez = 20;}
elseif($num <= 21000){$rez = 21;}
elseif($num <= 22000){$rez = 22;}
elseif($num <= 23000){$rez = 23;}
elseif($num <= 24000){$rez = 24;}
elseif($num <= 25000){$rez = 25;}
elseif($num <= 26000){$rez = 26;}
return $rez;
}

$sql = mysql_query('SELECT `id` FROM `kolhoz_user`');
while($inf = mysql_fetch_assoc($sql)){
mysql_query('UPDATE `kolhoz_user` SET `search_accelerator`="'.num_acc($inf['id']).'" WHERE `id`="'.$inf['id'].'"');
}
?>