HOME


Mini Shell 1.0
DIR:C:/Inetpub/vhosts/yantrashilpa.com/httpdocs/admin/
Upload File :
Current File : C:/Inetpub/vhosts/yantrashilpa.com/httpdocs/admin/view_subcategories.php
<!DOCTYPE html>
<html lang="en">
<?php session_start(); ?>
<?php include "../includes/db.php" ?>
<?php include "../admin/includes/header.php" ?>
<?php
if(isset($_POST['edit'])){
  $post_id=$_POST['post_id'];
  $img_title=$_POST['title'];
  $category=$_POST['category'];
  
  $query="UPDATE subcategories SET title ='{$img_title}',category = '{$category}' WHERE id={$post_id}";

  $result=mysqli_query($connection,$query);

 if($result){
   $_SESSION['edit_messages'] ="Successfully updated";
   
  }
  else{
    $_SESSION['edit_messages']="server error";
  }

}

if(isset($_GET['delete'])){
      $post_id=$_GET['delete'];
     
      $query="DELETE  FROM subcategories WHERE id={$post_id}";

      $delete_query=mysqli_query($connection,$query);
      if($delete_query){
         $_SESSION['edit_messages'] ="Successfully deleted";
        
        }
        else{
          $_SESSION['edit_messages']="server error";
      }
     
       


    }?>

  <body>
    <div class="container-scroller">
        <?php include "../admin/includes/topbar.php" ?>

        <div class="container-fluid page-body-wrapper">

        <?php include "../admin/includes/nav.php" ?>
        <!-- partial -->
        <div class="main-panel">
          <div class="content-wrapper">
            <div class="page-header">
              <h3 class="page-title">Manage Subcategories</h3>
              <nav aria-label="breadcrumb">
              </nav>
            </div>
            <div class="row">
              <div class="col-lg-12 grid-margin stretch-card">
                <div class="card">
                  <div class="card-body">
                    <h4 class="card-title">Subcategory List</h4>
                    <p class="card-description"></code>
                    </p>
                    <?php
                        if(isset($_SESSION['edit_messages'])){
                            echo "<div class='alert alert-primary'>";
                                echo "<span class='glyphicon glyphicon-remove'></span>&nbsp;".$_SESSION['edit_messages']."<br>";
                            echo "</div>";
                         unset($_SESSION['edit_messages']);
                        }
                    ?>  
                    <table class="table table-bordered" id="gallery">
                      <thead>
                        <tr>
                          <th> # </th>
                          <th>Category </th>
                          <th>Title </th>
                          <th>Action</th>
                        </tr>
                      </thead>
                      <tbody>
                    <?php
                        $query="SELECT * FROM subcategories";
                        $result=mysqli_query($connection,$query);
                        $count=mysqli_num_rows($result);
                        $i = 0;
                        while($row=mysqli_fetch_assoc($result)){
                        $i++;
                          ?>
                        <tr>
                          <td> <?php echo $i ?> </td>
                          <?php
                           $query1="SELECT * FROM categories where id = {$row['category']}";
                            $result1=mysqli_query($connection,$query1);
                           $row1=mysqli_fetch_assoc($result1)
                        ?>
                          <td> <?php echo $row1['title'] ?></td>
                       
                          <td> <?php echo $row['title'] ?></td>
                          <td><button class="btn btn-sm btn-primary"><a class="mdi mdi-delete"href="edit_subcategories.php?edit=<?php echo $row['id'] ?>" style="color:white">Edit</a></button>&nbsp;
                         <button class="btn btn-sm btn-danger"><a class="mdi mdi-delete"href="view_subcategories.php?delete=<?php echo $row['id'] ?>" style="color:white">Delete</a></button>
                        </td>
                        </tr>
                    <?php } ?>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
              
             
            </div>
          </div>
        </div>
        <!-- main-panel ends -->
      </div>
      <!-- page-body-wrapper ends -->
    </div>
    <!-- container-scroller -->
    <!-- plugins:js -->
    <script src="./vendors/js/vendor.bundle.base.js"></script>
    <!-- endinject -->
    <script src="./vendors/typeahead.js/typeahead.bundle.min.js"></script>
    <!-- End plugin js for this page -->
    <!-- inject:js -->
    <script src="./js/misc.js"></script>
    <!-- endinject -->
    <!-- Custom js for this page -->
    <script src="./js/typeahead.js"></script>
    <script src="./js/jquery.dataTables.min.js"></script>
    <!-- End custom js for this page -->
    <script type="text/javascript">
        $(document).ready( function () {
            $('.table').DataTable({
                // scrollY: '100px',
                
            });
        } );
    </script>
  </body>
</html>