Файл: 4mast/profmas.ru/pages/shop/incfiles/dir.php
Строк: 31
<?php
define('ROOT', $_SERVER['DOCUMENT_ROOT'].'/');
require_once(ROOT.'includes/Headers.php');
require_once(ROOT.'includes/PDO_func.php');
$id = isset($_GET['id']) ? abs((int)$_GET['id']) : false;
if (empty($id)) {
header ('location: /index.php');
exit;
}
$query = DB :: $dbs -> query ("SELECT * FROM `magazin_pr` WHERE `id`= ?", [$id]);
if ($query -> rowCount () == 0) {
header ('location: /index.php');
exit;
}
$pr = $query -> fetch ();
H ('Подраздел ' . $pr['name'], '<a href="/pages/shop" style="color:white;">Магазин</a> | ' . $pr['name']);
if($us == true) {
echo ' <a href="/pages/shop/addfiles/'.$id.'" class="block"><img src="/images/clean.png" alt=""/> Добавить Товар</a></div>';
}
$count = DB::$dbs->querySingle("SELECT COUNT(id) FROM magazin_file WHERE id_pr = ?", [$id]);
$items_per_page = 10;
$pages = ceil($count/$items_per_page);
$page = (int)$_GET['page'];
if ($page < 1) $page = 1;
if ($page > $pages)
$page = $pages;
$start = $page * $items_per_page - $items_per_page;
if ($count == 0) {
echo '<div class="error">Товаров нет!</div>';
}
else {
$sql = DB::$dbs->query("SELECT * FROM magazin_file WHERE id_pr = ? ORDER BY time DESC LIMIT $start, $items_per_page",[$id]);
while($a = $sql->fetch()) {
echo '<div class="block"><a href="/pages/shop/file/'.$a['id'].'">'.$a['name'].' ('.datef($a['time']).')<br/>Стоимость: <b><font color="green">'.$a['price'].'</font> р.</b></a></div>';
}
echo '' .page('/pages/shop/dir/'.$id.'?'). '';
}
require_once(ROOT.'includes/Footers.php');
?>