<?php
$id = isset($_GET['id']) ? abs((int)$_GET['id']) : false;
$query = DB :: $dbs -> query ("SELECT * FROM `magazin_r` WHERE `id` = ?",[$id]);
if ($query -> rowCount () == 0) {
header ('location: /');
exit;
}
$r = $query -> fetch ();
$title->SetTitle('Маркет - '.$r['name'].'');
$title->GetHeader();
echo'<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-widgets"></i><a href="/"style="text-decoration:none; color:white;"> Главная</a> :: <a href="/market"style="text-decoration:none; color:white;"> Маркет</a> :: ' . $r['name'].'</div></div></div>';
echo'<div class="t-body"><div class="list-group lg-alt">';
if (DB :: $dbs -> querySingle ("SELECT COUNT(id) FROM `magazin_pr` WHERE `id_r`= ?", [$r['id']])!=0) {
$query = DB::$dbs -> query("SELECT * FROM `magazin_pr` WHERE `id_r`= ?ORDER BY `id`", [$r['id']]);
while ($pr = $query -> fetch ()) {
echo '<div class="list-group-item media"><a href="/market/dir/' . $pr['id'] . '"><i class="zmdi zmdi-comments"></i>  ' . $pr['name'] . ' ('.DB :: $dbs -> querySingle ("SELECT COUNT(id) FROM `magazin_file` WHERE `id_pr`= ?", [$pr['id']]).')</div></a>';
}
} else {
err('Подразделов нет!');
}
echo'</div></div>';
?>