 <?php
 if(isset($_POST['show_product']))
 {
  ?>
<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;">Category Name</th>
          <th style="color:black;">Image</th>
          <th style="color:black;">Home Product</th>
          <th style="color:black;">Gallery</th>
          <th style="color:black;">Date</th>
          <th style="color:black;">Action</th>
        </tr>
        <?php
          $sn=0;
          $ReadSql = "select * from tbl_product";
          $sel = mysqli_query($link,$ReadSql);
        while($arr = mysqli_fetch_assoc($sel))
        {
          $cate_id=$arr['pro_category'];
          $sel1 = mysqli_query($link,"select * from tbl_category where cat_id=$cate_id");
          $arr1 = mysqli_fetch_assoc($sel1);
          $sn++;
        ?>
        <tr>
            <td><?=$sn?></td>
            <td><?=$arr['pro_name'];?></td>
            <td><?=$arr1['cate_name'];?></td>
            <td><img src="../product-image/<?=$arr['pro_image'];?>" alt="<?=$arr['pro_image'];?>" style="width:100px; height:100px;"></td>
            <td>
              <?php
              if($arr['status']=="Home")
              {
              ?>
              <form method="post">
                <input type="hidden" name="hid" value="<?=$arr['pro_id'];?>">
                <input type="submit" name="Remove" value="Remove" class="btn btn-danger">
              </form>
              <?php
              }
              else
              {
              ?>
              <form method="post">
                <input type="hidden" name="hid" value="<?=$arr['pro_id'];?>">
                <input type="submit" name="Add" value="Home" class="btn btn-success">
              </form>
              <?php
              }
              ?>
            </td>
             <td>
              <?php
              if($arr['status_gal']=="gallery")
              {
              ?>
              <form method="post">
                <input type="hidden" name="hid" value="<?=$arr['pro_id'];?>">
                <input type="submit" name="gal_rem" value="Remove" class="btn btn-danger">
              </form>
              <?php
              }
              else
              {
              ?>
              <form method="post">
                <input type="hidden" name="hid" value="<?=$arr['pro_id'];?>">
                <input type="submit" name="gal_rem" value="gallery" class="btn btn-success">
              </form>
              <?php
              }
              ?>
            </td>
            <td><?=$arr['pro_date']?></td>
            <td><a class="btn btn-success"  href="add-products.php?edit=<?=$arr['pro_id']?>">Edit</a>&nbsp;<a class="btn btn-danger" href="?del=<?=$arr['pro_id']?>">Delete</a></td>
        </tr>
        <?php
        }
        ?>
      </tbody>
    </table>
  </section>
  <?php
}
  ?>