<?php

include('config/dbcon.php');
include('authentication.php');
//session_start();

include('include/header.php');
?>

<div class="container-fluid px-4">
    
       <div class="row mt-4">
        <div class="col-md-12">
        <?php include('message.php'); ?>
         <div class="card">
                <div class="card-header">
                    <h4>All Gallery<a href="gallery-create.php" class="btn btn-primary float-end">Create gallery</a></h4>
                     
                </div>
                <div class="card-body">


                    <div class="table-responsive">
                            <table class="table bordered table-striped">
                                    <thead>
                                        <tr>
                                            <th>ID</th>
                                            <th>Title</th>
                                            
                                            <th>Select</th>
                                           <!-- <th>Status</th>
                                            <th>Edit</th>
                                            <th>Delete</th>-->
                                        </tr>
                                    </thead>
                                    <tbody>
                                            <?php
                           //     $post = "SELECT * FROM posts WHERE status!='2'";
//$gallery = "SELECT DISTINCT categories.name, gallery.category_id FROM categories INNER JOIN gallery ON categories.id = gallery.category_id Where categories.category_type = 'gallery'";
$gallery = "SELECT DISTINCT name, id FROM categories Where category_type = 'gallery' AND status = 0";


$gallery_run = mysqli_query($con, $gallery);

                                if(mysqli_num_rows($gallery_run)>0)
                                {

                                    foreach($gallery_run as $gallery)
                                    {
                                    ?>    
                                        <tr>
                                            <td><?= $gallery['id'] ?></td>
                                            <td><?= $gallery['name'] ?></td>
                                             
                                             
                                            <td>
                                                <a href="gallery-view.php?id=<?= $gallery['id'] ?>" class="btn btn-success">Go to Gallery</a>

                                            </td>
                                           
                                        </tr>


                                   <?php
                                    }

                                }else{
                                    ?> 
                                            <tr>
                                             <td colspan="7">No Record Found</td>
                                            </tr>

                                    <?php
                                }
                                    ?>


                                    </tbody>
                            </table>


                    </div>




                

                </div>

            </div>

        </div>

    </div>

</div>

<?php
include('include/footer.php');

include('include/script.php');

?>