File "gallery-view.php"

Full path: /home/fsibplc/public_html/admin/gallery-view.php
File size: 5.39 B (5.39 KB bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?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">
                    <?php 
                       
                       if (isset($_GET['id']) && filter_var($_GET['id'], FILTER_VALIDATE_INT)) {
                          $category_id = mysqli_real_escape_string($con, $_GET['id']); 
                     
                         
                         $stmt = $conn->prepare("SELECT name FROM categories Where id = ?"); 
                         $stmt->bind_param("i", $category_id);
                         $stmt->execute();
                         $result = $stmt->get_result();
                         $stmt->close();

                         while ($row = $result->fetch_assoc()) {
                              ?>
                                <h4>Gallery Name: <?php echo $categoryname= $row['name']; ?><a href="gallery-add.php?id=<?= htmlspecialchars($_GET['id']) ?>" class="btn btn-primary float-end">Add to gallery</a></h4>
                               <?php
                                                }
                                            
                         

                    }else {

                        echo "Invalid Parameter";
                        // Handle invalid input
                        // Redirect, display an error message, etc.
                    }

                    
                    ?>
                      
                </div>
                <div class="card-body">


                    <div class="table-responsive">
                            <table class="table bordered table-striped">
                                    <thead>
                                        <tr>
                                            <th>ID</th>
                                            <th>Title</th>
                                            <th>Image</th>
                                            <th>Status</th>
                                            <th>Edit</th>
                                            <th>Delete</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                            <?php
                            
                                $id= intval($_GET['id']);
                              
                                $gallery = "SELECT * FROM gallery Where category_id = '$id'";



                                $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['field_1'] ?></td>
                                            <td>
                                                <img src="../uploads/gallery/<?= $gallery['image'] ?>" width="60px" height="60px" />
                                            </td>
                                            <td>
                                                <?= $gallery['status'] == '1' ? 'Hidden':'Visible' ?>
                                            </td>
                                            <td>
                                                <a href="gallery-edit.php?id=<?= $gallery['id'] ?>&name=<?=$categoryname?>" class="btn btn-success">Edit</a>

                                            </td>
                                            <td>
                                                <form action="code.php" method="POST">
                                                <input type="hidden" name="category_id" value="<?=$id?>">
                                                
                                                <button type="submit" name="gallery_detete_btn" value="<?= $gallery['id'] ?>" class="btn btn-danger" onclick='return checkDelete()'>Delete</button>
                                                </form>
                                                

                                            </td>
                                        </tr>


                                   <?php
                                    }

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

                                    <?php
                                }
                                    ?>


                                    </tbody>
                            </table>


                    </div>




                

                </div>

            </div>

        </div>

    </div>

</div>
<script type="text/javascript">
        function checkDelete(){
            return confirm('Are you sure you want to delete this record?');
        }
</script>
<?php
include('include/footer.php');

include('include/script.php');

?>