<?php
include_once "config.php"; // Datubāzes savienojuma ietveršana.

$sql = "SELECT *
FROM `galerija`
ORDER BY `date`
DESC
LIMIT 15"; // SQL pieprasījums.

$result = $connection->query($sql); // SQL pieprasījuma nosūtīšana.

?>

<!DOCTYPE html>
<html lang="lv">
<head>
    <meta charset="UTF-8">
    <title>Galerija | Mirklis Elegances</title>
    <meta name="keywords" content="Galerija" />
    <meta name="description" content="Mirklis Elegances galerija." />
    <meta name="author" content="www.mirkliselegances.lv" />
    <meta name="robots" content="index, follow">
    <meta name="viewport" content="width=400, initial-scale=1.0">

    <!-- CSS -->
    <link rel="stylesheet" href="assets/css/galerija.css">
    <link rel="stylesheet" href="assets/css/header.css">
    <link rel="stylesheet" href="assets/css/footer.css">

    <!-- Bibliotēkas/Fonti -->
    <link rel="stylesheet" href="https://unpkg.com/aos@2.3.1/dist/aos.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Karla&display=swap">
    <script src="jquery.js" type="text/javascript"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

    <!-- Favikoni (bildītes cilnes augšā) -->
    <link rel="icon" type="image/png" href="assets/images/favicons/favicon-310x310.png" sizes="310x310" />
    <link rel="icon" type="image/png" href="assets/images/favicons/favicon-192x192.png" sizes="192x192" />
    <link rel="icon" type="image/png" href="assets/images/favicons/favicon-32x32.png" sizes="32x32" />
    <link rel="icon" type="image/png" href="assets/images/favicons/favicon-16x16.png" sizes="16x16" />

    <!-- Google Tag Manager (Sīkdatnes) -->
    <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
                new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
            j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
            'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
        })(window,document,'script','dataLayer','GTM-PFZ3WDD');
    </script>

    <!-- Google Tag Manager (noscript) -->
    <noscript>
        <iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PFZ3WDD" height="0" width="0" style="display:none;visibility:hidden"></iframe>
    </noscript>
</head>
<body class="scroll4">

<?php
include_once "cookie.php"; // Sīkdatņu informācijas faila ietveršana.
?>

<?php
include_once "header.php"; // Navigācijas joslas ietveršana.
?>

<!-- Pirmā sadaļa -->
<div class="items-bg" id="item1">
    <div class="items">
        <div class="textdiv1">
            <h1 class="title">Galerija</h1>
        </div>
        <div id="gallery-container">
            <?php // SQL pieprasījuma rezultāta pārstrādāšana.

            if ($result->num_rows > 0) { // Pārbauda vai vispār kas atgriezts.
                while ($row = $result->fetch_assoc()) { // Kamēr kaut kas ir masīvā tamēr ...
                    echo "
                    <div class='gallery-item'>
                        <img class='thumbnail2' src='assets/images/".$row["img"]."'>
                    </div>
                    ";
                }
            }
            ?>
        </div>
    </div>
</div>
<?php
include_once "footer.php"; // Kājenes ietveršana.
?>