<?php require_once("header.php");?>

      <!-- INTROTEXT -->
      <section class="intro-text" style="text-align: center;">
        <div data-aos="fade-down"  data-aos-delay="500">

        <h1 class="site-section-heading text-center mt-4">Digital Posters !</h1>
        <br>
        <h2 class="mt-3 mb-1">Can it be more simple?</h2>
        <h3 class="index-text mb-1">Choose your favorite motive, order and get it as an digitile file in your mailbox.</h3>
        <h3 class="index-text mb-1">Print the digital file at home or in a photo shop.</h3>
        <h3 class="index-text mb-1">Frame the picture the way you want it !</h3>
      </section>


    <div class="site-section"  data-aos="fade">
      <div class="container-fluid">

        <div class="row justify-content-center">

          <div class="col-md-7">
            <div class="row mb-5">
              <div class="col-12">
                <h2 class="site-section-heading text-center tight-space">Art Gallery</h2>
                
              </div>
            </div>
          </div>

        </div>
        <div class="row">  
       
       
        <?php

          // Skapa anslutning
          require_once 'db.php';
          
          // SQL-fråga för att hämta data
            $sql = "SELECT * FROM posters";
            
            // Utför frågan
            $result = $db->query($sql);
            
            // Kontrollera om det finns resultat
            if ($db->query($sql)) {
              // Hämta alla rader som en array
              $posters = $result->fetch_all(MYSQLI_ASSOC);
              //print_r($posters);
            } else {
              die( $db->error );
            }
            
            
            // Iterera över alla filmer
            foreach ($posters as $poster) {
            
              // Hämta data om varje $poster
              $id              = $poster['id'];
              $article_number  = $poster['article_number'];
              $product_name    = $poster['product_name'];
              $price           = $poster['price'];
              $description     = $poster['description'];
              $file_name       = $poster['file_name'];

              
              $description = "<a href='order.php?id=$id'>" . substr($description, 0, 20) . '... </a> <br>';
                                
        echo "
         
          <div class='col-12 col-md-4 px-4 item mb-4 aos-init aos-animate'>
          <img src='images/$file_name' alt='$product_name' class='img-fluid'>  
          <div class='mt-2'>    
          <h3 class='text-green text-center mt-4'>$product_name</h3>    
          <p class='mb-1'><strong>Article number:</strong> $article_number</p>    
          <p class='li-green-text mx-4'>$description Size: 70 cm x 50 cm.</p>    
          <p class='price-poster'>$price kr</p>  <div class='text-center'>    
          <a href='order.php?id=$id' class='btn btn-outline-white py-2 px-4'>BUY </a></div>  </div></div>

        ";

    
        } // foreach slutar här
            
        ?>


        </div>
      </div>
    </div>

    <?php require_once("footer.php");?> 