<?php
session_start();
include ('private/mysql.php');
include ('tmp/head.php');


switch($sd){
default:

header('Location: main.php');
exit;

break;



case 'inv':

$q = mysql_query("SELECT * FROM `item` WHERE `id`='$id' and `user`='$uid'");
$e = mysql_num_rows($q);
if($e=='0'){
    header('Location: inventar.php');
    exit;
}
$w = mysql_fetch_assoc($q);

if($w['status']=='odet'){
    $_SESSION['sell']="<font color=red>Вы не можете продать данную вещи,так как она одета на вас</font><hr>";
    header('Location: inventar.php');
    exit;
}

$cs1 = round($w['almaz']/5);
$cs2 = round($w['silver']/3);

mysql_query("UPDATE `users` SET `almaz`=`almaz`+'$cs1',`silver`=`silver`+'$cs2' WHERE `id`='$uid'");

if($w['almaz']!=='' and $w['almaz']!=='0'){$alm="<img src='img/almaz.png'> $cs1";}
if($w['silver']!=='' and $w['silver']!=='0'){$sil="<img src='img/silver.png'> $cs2";}

$_SESSION['sell']="<font color=lightgreen>Вы успешно продали $w[name] за $alm $sil</font><hr>";

mysql_query("DELETE FROM `item` WHERE `id`='$id' and `user`='$uid'");

header('Location: inventar.php');
exit;

break;



}
include ('tmp/foot.php');
?>