File "gallery-edit.php"

Full path: /home/fsibplc/public_html/admin/gallery-edit.php
File size: 10.46 B
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">
                    <h4>Edit Gallery<a href="all-gallery.php" class="btn btn-danger float-end">Back</a></h4>
                     
                </div>
                <div class="card-body">
                <?php
                  if (isset($_GET['id']) && filter_var($_GET['id'], FILTER_VALIDATE_INT)) {
                    $gallery_id = mysqli_real_escape_string($con, $_GET['id']); 
                  //  $gallery_id = $_GET['id'];
                    
                        $stmt = $conn->prepare("SELECT * FROM gallery WHERE id= ? LIMIT 1"); 
                        $stmt->bind_param("i", $gallery_id);
                        $stmt->execute();
                        $result = $stmt->get_result();
                        $stmt->close();

                    
                  
                 //   $gallery_query = "SELECT * FROM gallery WHERE id= '$gallery_id' LIMIT 1";
                 //   $gallery_query_res = mysqli_query($con, $gallery_query);

                    if(mysqli_num_rows($result) > 0)
                    {
                        $gallery_row = mysqli_fetch_array($result);
                        ?>


                    
                  
                <form action="code.php" method="POST" enctype="multipart/form-data">

                        <input type="hidden" name="gallery_id" value="<?= $gallery_row['id'] ?>">
                          
                            <div class="row">
                            <div class="col-md-6 md-3">
                                    <label for="">Category List</label>
                                    <?php 
                                        $status = 0;
                                         $stmt = $conn->prepare("SELECT * from categories WHERE status = ?");
                                         $stmt->bind_param("s", $status); 
                                         $stmt->execute();
                                         $category_run = $stmt->get_result();
                                     
                                        
                                    //    $category = "SELECT * from categories WHERE status ='0' ";
                                     //   $category_run = mysqli_query($con, $category);


                                        if(mysqli_num_rows($category_run) > 0 )
                                        {
                                            ?>
                                            <select name="category_id" required class="form-control">
                                                <option value="">--Select Category--</option>
                                                <?php 
                                                foreach($category_run as $categoryitem)
                                                { 
                                                ?>
                                                <option value="<?=$categoryitem['id']; ?>" <?= $categoryitem['id']==$gallery_row['category_id'] ? 'selected':''?> >
                                                     <?=$categoryitem['name']; ?>
                                                </option>
                                                <?php
                                                } 
                                                ?>

                                            </select>
                                           <?php     
                                        }else{

                                        }
                                    ?>
                                   
                                </div>
                                

                                <?php     //custom field for different category gallery start
                                            $category_name = mysqli_real_escape_string($con, $_GET['name']);  
                                              
                                            $stmt = $conn->prepare("SELECT name FROM categories Where name = ?"); 
                                            $stmt->bind_param("i", $category_name);
                                            $stmt->execute();
                                            $result = $stmt->get_result();
                                            $stmt->close();
                                    
                                   
                                /*   $query = "SELECT name FROM categories Where name = '$category_name'";
                                    $query_run = mysqli_query($con, $query);*/
                                    $result = mysqli_fetch_array($result);
                                
                                
                                    //   echo $result[0];  
                                if($result[0] == 'Testimonial'){
                                  ?>
                                        <div class="col-md-6 md-3">
                                        <label for="">Name</label>
                                            <input type="text" name="field_1" value="<?= $gallery_row['field_1']; ?>" required class="form-control">
                                        </div>
                                        <div class="col-md-6 md-3">
                                        <label for="">Profession</label>
                                            <input type="text" name="field_2" value="<?= $gallery_row['field_2']; ?>" required class="form-control">
                                        </div>
                                        <div class="col-md-6 md-3">
                                        <label for="">Star</label>
                                            <input type="number" name="field_3" value="<?= $gallery_row['field_3']; ?>" required class="form-control">
                                        </div>
                                         <div class="col-md-6 md-3">
                                        <label for="">Says</label>
                                            <input type="text" name="field_4"  value="<?= $gallery_row['field_4']; ?>" required class="form-control">
                                        </div> 
                                <?php }elseif($result[0] == 'Team'){?>
                                    
                                        <div class="col-md-6 md-3">
                                        <label for="">Name</label>
                                        <input type="text" name="field_1" value="<?= $gallery_row['field_1']; ?>" required class="form-control">
                                        </div>
                                        <div class="col-md-6 md-3">
                                            <label for="">Designation</label>
                                            <input type="text" name="field_2" value="<?= $gallery_row['field_2']; ?>" required class="form-control">
                                        </div>
                                        <div class="col-md-6 md-3">
                                            <label for="">Social Id</label>
                                            <input type="text" name="field_3" value="<?= $gallery_row['field_3']; ?>" required class="form-control">
                                        </div>
                                    
                                    
                                    
                                <?php }else{ //default field for gallery?>
                                    
                                    
                                    
                                        <div class="col-md-6 md-3">
                                        <label for="">Title</label>
                                            <input type="text" name="field_1" value="<?= $gallery_row['field_1']; ?>" required class="form-control">
                                        </div>
                                        <div class="col-md-6 md-3">
                                        <label for="">Sub Title</label>
                                            <input type="text" name="field_2" value="<?= $gallery_row['field_2']; ?>" required class="form-control">
                                        </div>
                                    
                                    
                                    
                                    
                                    <?php }   //custom field for different category gallery end
                                    ?>   







                              
                                
                                
                                <div class="col-md-6 md-3">
                                  <label for="">Image</label>
                                   
                                   <input type="hidden" name="old_image" value="<?= $gallery_row['image'] ?>">   
                                    <input type="file" name="image" class="form-control">
                                </div>
                                
                                       <input type="hidden" name="author" value="<?= $_SESSION['auth_user']['user_name'];?>" >
                                
                                <div class="col-md-6 md-3">
                                    <label for="Status">Status</label>
                                        <input type="checkbox" name="status" <?= $gallery_row['status'] == '1' ? 'checked':''?> width="70px" height="70px" />
                                        Checked = Hidden, Unchecked = Visible
                                </div>
                                <div class="col-md-6 md-3">
                                       <button type="submit" class="btn btn-primary" name="gallery_update">Update Gallery</button> 
                                </div>
                                
                            </div>
                        </form>



                        <?php

                }else{
                    ?>
                    <h4>No Record Found.</h4>

                    <?php
                }
                }
                ?>



                </div>
            </div>

        </div>

    </div>
</div>

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

include('include/script.php');

?>