<?php $aid=$_REQUEST['id']; ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>St Thomas Boys' High School</title>
    <link rel="icon" type="image/x-icon" href="../img/logo.png">

    <!--! css file link -->
    <link rel="stylesheet" href="../style.css">
    <link rel="stylesheet" href="../css/photo-gallery.css">
    <link rel="stylesheet" href="https://unpkg.com/aos@2.3.1/dist/aos.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery-js/1.4.0/css/lightgallery.min.css">

</head>
<body onload="typeWriter()">
    <div class="loader"></div> <!--! Loading animation-->
    <a class="to-top scale" href="#"><i class="fas fa-chevron-up"></i></a> <!--! Scroll to top button-->
    <header>
        <nav class="nav">
            <div class="container-1">
                <div class="nav-logo">
                    <figure>
                        <img src="../img/stbhs emblem colour-01.png" alt="" height="170px" width="" class="emblem scale">
                    </figure>
                </div>
                <div class="nav-content-container">
                    <h3 data-aos="fade-left" 
                        data-aos-anchor-placement="center-center" 
                        data-aos-once="true">Society of the missionaries of St Francis De Sales (M.S.F.S)</h3>
                    <h1 id="typing-effect"></h1>
                    <h3 data-aos="fade-right" data-aos-anchor-placement="center-center" data-aos-once="true">Aldona -
                        Goa 403-508</h3>
                </div>
                <div class="nav-badge">
                    <figure>
                        <img src="../img/logo.png" alt="" height=200px width=200px class="logo scale">
                    </figure>
                </div>
            </div>
            <div class="container-2">
                <div class="topnav" id="myTopnav">
                    <a href="../index.html" class="active a-button">HOME</a>
                    <div class="dropdown">
                        <button class="dropbtn">
                            ABOUT US&nbsp;
                            <i class="fa fa-caret-down"></i>
                        </button>
                        <div class="dropdown-content">
                            <a href="principals-message.html">Principal's Message</a>
                            <a href="directors-message.html">Director's Message</a>
                            <a href="patron.html">Patron Saint</a>
                            <a href="history.html">History</a>
                        </div>
                    </div>
                    <div class="dropdown">
                        <button class="dropbtn">
                            ACADEMICS&nbsp;
                            <i class="fa fa-caret-down"></i>
                        </button>
                        <div class="dropdown-content">
                            <a href="staff.html">Our Staff</a>
                            <a href="achievers.html">Our Achievers</a>
                            <!-- <a href="leaders.html">Our House Leaders</a> -->
                        </div>
                    </div>
                    <div class="dropdown">
                        <button class="dropbtn">
                            EVENTS GALLERY&nbsp;
                            <i class="fa fa-caret-down"></i>
                        </button>
                        <div class="dropdown-content">
                            <a href="competitions-album-gallery.php">Competitions & Events</a>
                            <!-- <a href="sports-gallery-primary.html">Sports Activities</a> -->
                            <a href="celebrations-album-gallery.php">Celebrations</a>
                        </div>
                    </div>
                    <!-- <a href="html/campus.html" class="a-button">CAMPUS</a> -->
                    <a href="contact-us.html" class="a-button">CONTACT US</a>
                    <a href="javascript:void(0);" style="font-size: 20px" class="icon"
                        onclick="myFunction()">&#9776;</a>
                </div>
            </div>
        </nav>
    </header>
    <main class="main-content">
    <section class="gallery-section">
            <div class="gallery-section-container">
                <?php
                    include 'connect.php';
                    $sql = "SELECT * FROM stbhs_album WHERE albumid='$aid'";
                    $rs_result = mysqli_query($con, $sql);
                    while ($row = mysqli_fetch_assoc($rs_result)) 
                    {
                        $aimage=$row['image'];
                        $aname=$row['name'];
                        $adesc=$row['adesc'];
                        $astatus=$row['status'];
                        $category=$row['category'];
                        $category=strtoupper($category);
                ?>
                <?php echo" <h2>$aname</h2>" ?>
                <hr>
                <br><br>
                <?php echo" <div class='album-description'><p>$adesc</p></div>" ?>
                <?php
                    }
                ?>
                    <div class="gallery">
                    <?php
                        include 'connect.php';

                        $limit = 18;
                        $page = isset($_GET['page']) ? $_GET['page'] : 1;
                        $offset = ($page - 1) * $limit;
            
                        $sql = "SELECT * FROM stbhs_gallery WHERE aid=$aid AND status='process' ORDER BY gimages ASC LIMIT $offset, $limit";
                        $num_rows = mysqli_num_rows(mysqli_query($con, $sql));
                        $result = mysqli_query($con, $sql);
                        
                        while ($row = mysqli_fetch_array($result)) {
                            $gimage = $row['gimages'];
                    ?> 
                        <?php echo "<a href='../admin/gupload/$gimage'><img src='../admin/gcatch/$gimage' alt='' data-aos='zoom-in-up' data-aos-once='true'></a>";?>
                        <?php } ?>
                    </div>
            </div>
            <div class="pagenation">
                <?php
                $sql = "SELECT COUNT(*) FROM stbhs_gallery where aid=$aid and status='process'";
                $result = mysqli_query($con, $sql);
                $total_rows = mysqli_fetch_array($result)[0];		
                $total_pages = ceil($total_rows / $limit);

                $prev_page = max(1, $page - 1);
                echo "<a href='?id=$aid&page=1' class='special-btn" . ($page == 1 ? " active-page" : "") . "'><i class='fas fa-step-backward scale'></i></a>";
                echo "<a href='?id=$aid&page=$prev_page' class='special-btn'><i class='fas fa-chevron-left scale'></i></a>";
                
                echo "<div>";
                for($i = 1; $i <= $total_pages; $i++) {
                    echo "<a href='?id=$aid&page=$i' class='every-page".($page == $i ? " active-page" : "")."'>$i</a>";
                }
                echo "</div>";
                $next_page = min($total_pages, $page + 1);
                echo "<a href='?id=$aid&page=$next_page' class='special-btn'><i class='fas fa-chevron-right scale'></i></a>";
                echo "<a href='?id=$aid&page=$total_pages' class='special-btn" . ($page == 1 ? " active-page" : "") . "'><i class='fas fa-step-forward scale'></i></a>";
                ?>
            </div>

                        
        </section>
    </main>
    <footer class="footer">
        <div class="footer-container">
            <div class="row">
                <div class="footer-col">
                    <h2>ST THOMAS BOYS' HIGH SCHOOL</h2>
                    <figure>
                        <img src="../img/stbhs emblem colour-01.png" class="scale" alt="" width=100px height=100px>
                    </figure>
                </div>
                <div class="footer-col">
                    <h4>Quick Links</h4>
                    <ul>
                        <li><a href="../index.html">Home</a></li>
                        <li><a href="https://www.gbshse.in" target="_blank">Goa Board</a></li>
                        <li><a href="https://www.goa.gov.in" target="_blank">Directorate of Education</a></li>
                        <!-- <li><a href="#">Fee Online Payment</a></li> -->
                        <li><a href="achievers.html">Achievements & Achievers</a></li>
                        <!-- <li><a href="#">STBHS Committees & Cells</a></li> -->
                    </ul>
                </div>
                <div class="footer-col">
                    <h4>Other Links</h4>
                    <ul>
                        <li><a href="patron.html">About Us</a></li>
                        <li><a href="co-curricular-gallery-primary.html">Events Gallery</a></li>
                        <li><a href="rules-regulations.html">Rules & Regulations</a></li>
                        <li><a href="contact-us.html">Contact us</a></li>
                    </ul>
                </div>
                
                <div class="footer-col">
                    <h4>Follow us on</h4>
                    <div class="social-links scale">
                        <a href="https://www.facebook.com/groups/1063578354592364/?ref=share&mibextid=NSMWBT"><i
                                class="fab fa-facebook-f scal"></i></a>
                        <a href="#"><i class="fab fa-whatsapp scal"></i></a>
                        <a href="#"><i class="fab fa-instagram scal"></i></a>
                    </div>
                </div>
                <div class="footer-col">
                    <p>
                        Developer : <a href="developer.html" class="unstyled-link">Haysten D'costa</a>
                        <br>haystend@gmail.com
                    </p>
                    <br>
                    <div class="social-links scale">
                        <a href="https://github.com/Haysten-D-costa/" target="_blank"><i class="fab fa-github scal"></i></a>
                        <a href="https://www.instagram.com/haysten_d_costa/" target="_blank"><i class="fab fa-instagram scal"></i></a>
                        <a href="https://www.linkedin.com/in/haysten-d-costa-625515252/" target="_blank"><i class="fab fa-linkedin-in scal"></i></a>
                    </div>
                </div>
            </div>
        </div>
    </footer>
    <section class="copyright-section">
        <h4>COPYRIGHT &copy; &nbsp;&nbsp;&nbsp;&nbsp; 2024 St Thomas Boys' High School | <i>Haysten D'costa<i></h4>
    </section>


    <script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery-js/1.4.0/js/lightgallery.min.js"></script>
    <script>
        lightGallery(document.querySelector('.gallery'));
    </script>
    <script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
    <script src="../script.js"></script>   
    <script>
        AOS.init();
    </script>
</body>
</html>