<?
   $speak = $_GET['speak'];
   $buy = $_GET['buy'];
$tr = mysql_query("SET NAMES cp1251");
$tr = mysql_query("SELECT * FROM shop_items WHERE SPCLS=\"$cat\" AND SPTRG=\"$speak\" AND SPCNT>0");
$torg = mysql_query("SELECT * FROM npc_world WHERE npc_src=\"$speak\" AND torg=\"1\"");
if(mysql_num_rows($tr)<1){echo"<div class=\"main_title\"><center>в данной категории нет не одного предмета!</center></div>";exit;}
if(mysql_num_rows($torg)<1){echo"<div class=\"main_title\"><center>Данный нпс не является торговцем!</center></div>";exit;}
if(mysql_num_rows($tr)>0 AND mysql_num_rows($torg)>0){

  while($tr2 = mysql_fetch_assoc($tr)){
  echo"<pre>
  <img src=\"$tr2[SPIMG]\"> $tr2[SPNME] [инфо]
        ";
		if($tr2[SPSBS] == 'gold'){echo"<img src=\"img/gold.png\"> $tr2[SPCST]
        <img src=\"img/drop.png\"> $tr2[SPCNT]<br/>";}
		if($tr2[SPSBS] == 'br'){echo"<img src=\"img/br.png\" height=\"11\" width=\"12\"> $tr2[SPCST]
        <img src=\"img/drop.png\"> $tr2[SPCNT]<br/>";}
		if($tr2[SPSBS] == 'stock'){echo"<img src=\"img/stock.png\" height=\"11\" width=\"12\"> $tr2[SPCST]
        <img src=\"img/drop.png\"> $tr2[SPCNT]<br/>";}
echo"<a href=\"game.php?speak=$speak&id=$id&cat=$cat&buy=$tr2[SPKEY]\"> <div class=\"button\">купить</div></a>
       </pre>";
  $tov = mysql_query("SELECT * FROM shop_items WHERE SPCLS=\"$cat\" AND SPTRG=\"$speak\" AND SPCNT>0 AND SPKEY=\"$buy\"");
  $tov2 = mysql_fetch_assoc($tov);
  
$tovar = $tov2[SPNME];
$cst = $tov2[SPCST];
$va = $tov2[SPSBS];                                               }
   if(isset($buy)){
   echo"<div class=\"main_title\"><center>вы успешно купили $tovar за <img src=\"img/$va.png\" height=\"11\" width=\"12\"> $cst</center></div>";
                   }
				   }
?>