  <?php 
     require('top.php');
if (isset($_GET['type']) && $_GET['type']!='') {
   $type=mysqli_real_escape_string($con,$_GET['type']);
        if($type=='delete'){
                     $id=mysqli_real_escape_string($con,$_GET['id']);
                     $delete_sql="delete from contact_us where id='$id'";
                     mysqli_query($con,$delete_sql);

   }
}

$sql="select * from contact_us order by id desc";
$res=mysqli_query($con,$sql);
  ?>


  <div class="clearfix"></div>
                <!-- Orders -->
                <div class="orders">
                    <div class="row">
                        <div class="col-xl-12">
                            <div class="card">
                                <div class="card-body">
                                    <h4 class="box-title">Contact Us</h4>
                                </div>
                                <div class="card-body--">
                                    <div class="table-stats order-table ov-h">
                                        <table class="table ">
                                            <thead>
                                                <tr>
                                                    <th class="serial">#</th>
                                                    <th>ID</th>
                                                    <th>Name</th>
                                                    <th>Email</th>
                                                    <th>Mobile</th>
                                                    <th>Comment</th>
                                                    <th>Date</th>
                                                    <th></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                               <?php
                                                $i=1;
                                                while ($row=mysqli_fetch_assoc($res)){    
                                               ?>
                                                <tr>
                                                    <td class="serial"><?php echo $i ?></td>
                                                    <td><?php echo $row['id']  ?></td>
                                                    <td><?php echo $row['name']  ?>
                                                    <td><?php echo $row['email']  ?>
                                                     <td><?php echo $row['mobile']  ?>
                                                    <td><?php echo $row['comment']  ?>
                                                     <td><?php echo $row['added_on']  ?>
                                                    </td>
                                                    <td>
                                                      <?php 
                                                    
                                                       echo "<span class='badge badge-delete'><a href='?type=delete&id=".$row['id']."'> Delete</a></span>&nbsp;";

                                                      ?></td>
                                                </tr>
                                               <?php }  ?>
                                            </tbody>
                                        </table>
                                    </div> <!-- /.table-stats -->
                                </div>
                            </div> <!-- /.card --> 
                        </div> <!-- /.col-lg-12 -->
 <?php 
     require('footer.php');
     
  ?>
                     