Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('php/bd.php');
- require_once('php/function.php');
- if(!empty([$_GET['categories']]) or !empty($_GET['new']) or !empty($_GET['sale'])) {
- $where = "";
- if($_GET['categories']) {
- $where = addWhere($where, "`categories` = '".htmlspecialchars($_GET["categories"])."'");
- }
- if($_GET['new']) {
- $where = addWhere($where, "`new` = '1'");
- }
- if($_GET['sale']) {
- $where = addWhere($where, "`sale` = '1'");
- }
- if($_GET['min-price'] or $_GET['max-price']) {
- $where = addWhere($where, "`price` BETWEEN '".htmlspecialchars($_GET["min-price"])."' and '".htmlspecialchars($_GET["max-price"])."'");
- }
- if($_GET['sort']) {
- $where .= " ORDER BY price ".htmlspecialchars($_GET['sort']);
- }
- if ($where) {
- $sql = "WHERE $where";
- }
- }
- $query = $pdo->query("SELECT * FROM (SELECT ID FROM `tovaru` $sql) as ID, (SELECT MIN(`price`) as min_price, MAX(`price`) as max_price FROM `tovaru` $sql) as price");
- $price = $query->fetch(PDO::FETCH_ASSOC);
- $count = $query->rowCount();
- $kol = 9; // Количество записей на одну страницу
- ?>
- <!DOCTYPE html>
- <html lang="ru">
- <head>
- <meta charset="utf-8">
- <title>Fashion</title>
- <meta name="description" content="Fashion - интернет-магазин">
- <meta name="keywords" content="Fashion, интернет-магазин, одежда, аксессуары">
- <meta name="theme-color" content="#393939">
- <link rel="preload" href="img/intro/coats-2018.jpg" as="image">
- <link rel="preload" href="fonts/opensans-400-normal.woff2" as="font">
- <link rel="preload" href="fonts/roboto-400-normal.woff2" as="font">
- <link rel="preload" href="fonts/roboto-700-normal.woff2" as="font">
- <link rel="icon" href="img/favicon.png">
- <link rel="stylesheet" href="css/style.css">
- <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
- <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
- <script src="js/scripts.js" defer=""></script>
- </head>
- <body>
- <header class="page-header">
- <a class="page-header__logo" href="#">
- <img src="img/logo.svg" alt="Fashion">
- </a>
- <nav class="page-header__menu">
- <ul class="main-menu main-menu--header">
- <li>
- <a class="main-menu__item" href="#">Главная</a>
- </li>
- <li>
- <a class="main-menu__item" href="#">Новинки</a>
- </li>
- <li>
- <a class="main-menu__item active">Sale</a>
- </li>
- <li>
- <a class="main-menu__item" href="delivery.html">Доставка</a>
- </li>
- <li>
- <a class="main-menu__item" href="authorization.html">Кабинет</a>
- </li>
- </ul>
- </nav>
- </header>
- <main class="shop-page">
- <header class="intro">
- <div class="intro__wrapper">
- <h1 class=" intro__title">COATS</h1>
- <p class="intro__info">Collection 2018</p>
- </div>
- </header>
- <section class="shop container">
- <section class="shop__filter filter">
- <form> // ФОРМА
- <div id="message"></div>
- <div class="filter__wrapper">
- <b class="filter__title">Категории</b>
- <ul class="filter__list">
- <?
- if(isset($_GET['categories'])) {
- ?><input class="categories" type="hidden" name="categories" value="<?=$_GET['categories']?>"><?
- }
- ?>
- <li>
- <a class="filter__list-item <? if(!isset($_GET['categories'])) { echo 'active'; } ?>" href="index.php">Все</a>
- </li>
- <li>
- <a class="filter__list-item <? if($_GET['categories'] == 'girl') { echo 'active'; } ?>" href="?categories=girl">Женщины</a>
- </li>
- <li>
- <a class="filter__list-item <? if($_GET['categories'] == 'boy') { echo 'active'; } ?>" href="?categories=boy">Мужчины</a>
- </li>
- <li>
- <a class="filter__list-item <? if($_GET['categories'] == 'children') { echo 'active'; } ?>" href="?categories=children">Дети</a>
- </li>
- <li>
- <a class="filter__list-item <? if($_GET['categories'] == 'accessories') { echo 'active'; } ?>" href="?categories=accessories">Аксессуары</a>
- </li>
- </ul>
- </div>
- <div class="filter__wrapper">
- <b class="filter__title">Фильтры</b>
- <div class="filter__range range">
- <span class="range__info">Цена</span>
- <div class="filter_all range__line" aria-label="Range Line"></div>
- <div class="range__res">
- <?
- if(isset($_GET['min-price'])) {$min = htmlspecialchars($_GET['min-price']);} else {$min = $price['min_price'];}
- if(isset($_GET['max-price'])) {$max = htmlspecialchars($_GET['max-price']);} else {$max = $price['max_price'];}
- ?>
- <input type="hidden" name="min-price" id="min-price-hide" value="<?=$min?>">
- <input type="hidden" name="max-price" id="max-price-hide" value="<?=$max?>">
- <span class="range__res-item min-price"><?=$min?></span>
- <span class="range__res-item max-price"><?=$max?></span>
- </div>
- </div>
- </div>
- <fieldset class="custom-form__group">
- <input type="checkbox" name="new" value="1" class="filter_all new" <? if(isset($_GET['new'])) { echo 'checked'; } ?>>Новинки<br>
- <input type="checkbox" name="sale" value="1" class="filter_all sale" <? if(isset($_GET['sale'])) { echo 'checked'; } ?>>Распродажа
- </fieldset>
- <button class="button" type="submit" style="width: 100%">Применить</button>
- </form>
- </section>
- </form>
- <div class="shop__wrapper">
- <section class="shop__sorting">
- <div class="shop__sorting-item custom-form__select-wrapper">
- <select class="custom-form__select" name="category">
- <option hidden="">Сортировка</option>
- <option class="sort" value="ASC">От дешевых к дорогим</option>
- <option class="sort" value="DESK">От дорогих к дешевым</option>
- </select>
- </div>
- <p class="shop__sorting-res">Найдено <span class="res-sort"><?=$count?></span> моделей</p>
- </section>
- <section class="shop__list">
- <?php
- if (isset($_GET['page'])){
- $page = $_GET['page'];
- }
- else {
- $page = 1;
- }
- $art = ($page * $kol) - $kol;
- $query = $pdo->query("SELECT * FROM `tovaru` $sql LIMIT $art, $kol");
- while($row = $query->fetch(PDO::FETCH_ASSOC)) {
- ?>
- <article class="shop__item product" tabindex="0">
- <div class="product__image">
- <img src="img/products/<?=$row['img']?>" alt="product-name">
- </div>
- <p class="product__name"><?=$row['name']?></p>
- <span class="product__price"><?=$row['price']?></span>
- </article>
- <?php
- }
- ?>
- </section>
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement