<?php
$page_title = 'Битва отрядов';
include_once 'conf/dbc.php';
include_once 'conf/session_start.php';
include_once 'conf/head.php';
include_once 'conf/top.php';
$usid = abs(intval($_SESSION['id']));
$user = $pdo->query("SELECT * FROM users WHERE id='".$usid."'")->fetch();
$clanid = $user['clan'];
$clan= $pdo->query("SELECT * FROM clans WHERE clan_id='$clanid'")->fetch();
$bitva = $pdo->query("SELECT * FROM bitva WHERE clan_id='".$clanid."' or clan_pr_id='".$clanid."'")->fetch();
$clan_nap= $pdo->query("SELECT * FROM clans WHERE clan_id='".$bitva[clan_id]."'")->fetch();
$clan_pr= $pdo->query("SELECT * FROM clans WHERE clan_id='".$bitva[clan_pr_id]."'")->fetch();

$query = "Select * from bitva  WHERE `clan_id` = '$clanid' or `clan_pr_id` = '$clanid' LIMIT 1";
$for= mysqli_query($dbc, $query) or die ('Ошибка передачи запроса к БД');
$avto = mysqli_num_rows($for);
if($avto==0){header('location: clan.php?id='.$clanid.'');
exit();}
if($user[clan]<=0){header('location: index.php');
exit();}
if($clan[bitva]<=0){header('location: clan.php?id='.$clanid.'');
exit();}
echo'
<div class="r6">
<table>
<tr>
<td style="width: 50%">
<div class="r2">
<center>
<img src="img/clan_av/'.$clan_nap[ava].'" style="width: 60%; height: 110px;"/></center>
</div>
</td>
<td style="width: 50%">
<div class="r2">
<center>
<img src="img/clan_av/'.$clan_pr[ava].'" style="width: 60%; height: 110px;"/></center>
</div>
</td>
</tr>
</table>
<div class="r6"><center>
<p class="net">Отряд <a class="stalker_link" href="clan.php?id='.$clan_nap[clan_id].'">'.$clan_nap[name].'</a> напал на отряд <a class="stalker_link" href="clan.php?id='.$clan_pr[clan_id].'">'.$clan_pr[name].'</a>.<br/> Битва начнётся через '.$clan_nap[time_start].' минут.<br/> Есть время прихватить лишнюю обойму патронов.</p></center>
</div>
</div>
';
include_once 'conf/navig.php';
include_once 'conf/foot.php';
?>