<?php include('site-header.php'); ?>
  <!-- end of LOGO CONTAINER -->
  <!-- - - - - - - - - - - - - -->
  <!-- start of SIDEBAR        -->
  <!-- - - - - - - - - - - - - -->
  <?php include('left-nevigation.php'); ?>
  
  <!-- - - - - - - - - - - - - -->
  <!-- end of SIDEBAR          -->
  <!-- - - - - - - - - - - - - -->
  <main id="playground">
    <!-- - - - - - - - - - - - - -->
    <!-- start of TOP NAVIGATION -->
    <!-- - - - - - - - - - - - - -->
 <?php include('site-top-header.php'); ?>

    <!-- - - - - - - - - - - - - -->
    <!-- end of TOP NAVIGATION   -->
    <!-- - - - - - - - - - - - - -->
    <!-- PAGE TITLE -->
    <?php
    $id = mysqli_real_escape_string($link,$_GET['del']);
    $sel = mysqli_query($link,"select * from tbl_small_banner2 where pro_id=$id");
    $arr = mysqli_fetch_assoc($sel);
    if(isset($_GET['del']))
    {
        $image = $arr['pro_image'];
        $id = $_GET['del'];
        if(mysqli_query($link,"DELETE FROM `tbl_small_banner2` WHERE id=$id"))
        {
          unlink("../product-image/$image");
          echo "<script>window.location.href='product-item.php';</script>";
        }
    }
    ?>
    <section id="page-title" class="row">
      <div class="col-md-8">
        <h1>Show Product</h1>
        <p class="lead">Update your product</strong>.</p>
      </div>
      <div class="col-md-4">
      </div>
    </section>
    <!-- / PAGE TITLE -->
    <div class="container-fluid">
      <div class="row">
        <div class="col-md-4">
          <section class="panel tasks-widget"></section>
        </div>
        <div class="col-md-4">
          <div class="panel-body"> <form method="post">
             <div class="form-group text-center"><a href="add-products.php" class="btn btn-primary">Add New Product</a>&nbsp;</div>
          </form>
          </div>
        </div>
        <div class="col-md-4">
          <section class="panel tasks-widget"></section>
        </div>
      </div>
      <!-- / row -->
      <div class="row">
        <div class="col-md-12">
          <section class="panel panel-primary">
            <header class="panel-heading">
              <h3 class="panel-title">Existing Product</h3>
            </header>
            
            <table class="table table-hover table-responsive" width="100%">
            <tbody>
              <tr>
                <th scope="row" style="color:black;">S. No</th>
                <th style="color:black;">Product Name</th>
                <th style="color:black;">Product Sub Name</th>
                <th style="color:black;">Add Gallery</th>
                <th style="color:black;">Image</th>
                <th style="color:black;">Date</th>
                <th style="color:black;">Action</th>
              </tr>
              <?php
                $sn=0;
                $ReadSql = "SELECT * FROM `tbl_small_banner2`  ORDER BY id DESC";
                $sel = mysqli_query($link,$ReadSql);
              while($arr = mysqli_fetch_assoc($sel))
              {
                
                $sn++;
              ?>
              <tr id="<?=$arr['pro_id'];?>">
                  <td><?=$sn?></td>
                  <td><?=$arr['pro_name'];?></td>
                  <td><?=$arr['pro_sub_name'];?></td>
                  <td><a href="add-product-gallery.php?pro_id=<?=$arr['id']?>" class="btn btn-primary">Add</a></td>
                  <td>
                    <img src="../product-image/<?=$arr['image'];?>" alt="<?=$arr['image'];?>" style="width:100px; height:100px;">
                  </td>
                  <td><?=$arr['date']?></td>
                  <td><a class="btn btn-success"  href="add-products.php?edit=<?=$arr['id']?>">Edit</a>&nbsp;<a class="btn btn-danger" href="?del=<?=$arr['id']?>">Delete</a></td>
              </tr>
              <?php
              }
              ?>
          </tbody>
            </table>
          </section>
        </div>
      </div>
    </div>
    <!-- / container-fluid -->
 <?php include('site-footer.php'); ?>
