<?php
echo "<div class='aut'>Мои постройки</div>\n";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `empire_stroi` WHERE `id_u`='".$user['id']."'"),0)=='0'){
echo "<div class='err'>У вас нет зданий! Для постройки зданий вам необходимы строители</div>\n";
}
else
{
  $p=abs(intval($_GET['p']));
  if($p=='0'){
  $all_p=mysql_result(mysql_query("SELECT COUNT(*) FROM `empire_stroi` WHERE `id_u`='".$user['id']."'"),0);
  $k_page=k_page($all_p,$set['p_str']);
  $page=page($k_page);
  $start=$set['p_str']*$page-$set['p_str'];
  $my_p=mysql_query("SELECT * FROM `empire_stroi` WHERE `id_u`='".$user['id']."' ORDER BY `id` LIMIT $start,$set[p_str]");
  while($arr=mysql_fetch_array($my_p)){
###
if($num==1){ 
echo "<div class='f1'>"; 
$num=0;}
else{ 
echo "<div class='f2'>"; 
$num=1;}
###
echo "<img src='buildings.PNG'> <a href='?do=7&amp;p=$arr[id]'>$arr[name]</a><br/>";
###
echo "</div>";
###
}
if($k_page>'1')str('?do=7&amp;',$k_page,$page);
}else{
$all_p=mysql_result(mysql_query("SELECT COUNT(*) FROM `empire_stroi` WHERE `id`='".$p."' AND `id_u`='".$user['id']."'"),0);
if($all_p>'0'){
$my_p=mysql_fetch_array(mysql_query("SELECT * FROM `empire_stroi` WHERE `id`='".$p."'"));
  
echo "<div class='aut'>$my_p[name]</div>\n
<div class='f1'>Еда: +$my_p[eda]</div>\n
<div class='f1'>Дерево: +$my_p[derevo]</div>\n
<div class='f1'>Золото: +$my_p[zoloto]</div>\n
<div class='f1'>Железо: +$my_p[gelezo]</div>\n
<div class='f1'>Воины: +$my_p[voin]</div>\n
<div class='f1'>Пушки: +$my_p[push]</div>\n";
$cherez=$my_p['time_r']-time();
if($cherez>='1'){
echo "<div class='f1'>Прибыль через : ".sictime($cherez)." сек</div>\n";
}
echo "<div class='glav'><a href='?do=20&amp;id=$p'>Продать постройку</a></div>\n";;

if($my_p['time_r']<=time()){
      $ntime=time()+60*60*3;
      $zoloto=$my_p['zoloto']*$q['zoloto_l'];
      $eda=$my_p['eda']*$q['eda_l'];
      $derevo=$my_p['derevo']*$q['dr_l'];
      $gelezo=$my_p['gelezo']*$q['gelezo_l'];
      $voin=$my_p['voin'];
      $push=$my_p['push'];

mysql_query("UPDATE `empire` SET `eda`=`eda`+$eda, `zoloto`=`zoloto`+$zoloto, `derevo`=`derevo`+$derevo, `gelezo`=`gelezo`+$gelezo, `voin`=`voin`+$voin, `push`=`push`+$push WHERE `id_u`='$user[id]' LIMIT 1");
mysql_query("UPDATE `empire_stroi` SET `time_r`='$ntime' WHERE `id`='$p' LIMIT 1");

msg('Налоги успешно собраны');
}}}}
echo "<div class='aut'><a href='?do=0'>Назад</a></div>";
?>