<?php 
require ("top.php"); 

if(isset($_GET['type']) && $_GET['type']!=''){
    $type = mysqli_real_escape_string($con,$_GET['type']);

    if($type=='status'){
        $operation = mysqli_real_escape_string($con,$_GET['operation']); 
        $id = mysqli_real_escape_string($con,$_GET['id']);
        if($operation=='active'){
            $status='1';
        }else{
            $status='0';
        }
        $update_status_sql = "update user_register set status = '$status' where id='$id'";
        mysqli_query($con,$update_status_sql);
    }

    if($type=='delete'){ 
        $id = mysqli_real_escape_string($con,$_GET['id']);
        $delete_sql = "Delete from user_register where id='$id'";
        mysqli_query($con,$delete_sql);
    }
}

$sql = "select * from user_register order by id desc";
$res=mysqli_query($con,$sql);
?>
 margin-left:220px;
<div class="col-sm-9 mx-auto my-4" style="width: 2000px;" >
    <div class="col-sm-12">
        <div class="card" style="width: 2000px;">
            <div class="card-body">
                <h4>Users</h4>
            </div>
            <table class="table table-flush">
                <thead>
                    <tr class="bg-secondary">
                        <th>#</th>
                        <th> Name</th>
                        <th>Email</th>
                        <th>Password</th>
                        <th>City</th>
                        <th>Country</th>
                        <th>Student or Professional</th>
                        <th>Collage Name</th>
                        <th>Organisation Name(For Professional)</th>
                        <th> Experience </th>
                       
                        <th>Purpose Of Certification</th>
                        <th>Mobile No</th>
                        <th>Status</th>
                        <th>Doc</th>
                        <th>Date</th>
                        <th>Action</th>
                        <th>Delete</th>
                    </tr>
                </thead>
                <tbody>
                    <?php 
                    $i=1;
                    while($row=mysqli_fetch_assoc($res)){ ?>
                    <tr>
                        <td><?php echo $i++ ?></td>
                        <td><?php echo $row['username'] ?></td>
                        <td><?php echo $row['email'] ?></td>
                        <td><?php echo $row['password'] ?></td>
                        <td><?php echo $row['city'] ?></td>
                        <td><?php echo $row['country'] ?></td>
                        <td><?php echo $row['student'] ?></td>
                        <td><?php echo $row['collage'] ?></td>
                        <td><?php echo $row['organisation'] ?></td>
                        <td><?php echo $row['years'] ?></td>
                        <td><?php echo $row['purpose'] ?></td>
                        <td><?php echo $row['mobile'] ?></td>
                        <td><?php echo $row['status'] ?></td>
                        <td>
                            <a href="download.php?file=<?php echo $row['doc1'] ?>">Doc1</a>
                            <a href="download.php?file=<?php echo $row['doc2'] ?>">Doc2</a>
                            <a href="download.php?file=<?php echo $row['doc3'] ?>">Doc3</a>
                        </td>
                        <td>
                        <?php 
                        if($row['status']==1){
                            echo "<a class='badge badge-success' href='?type=status&operation=deactive&id=".$row['id']."'>Active</a>&nbsp;";
                        }else{
                            echo "<a class='badge badge-warning' href='?type=status&operation=active&id=".$row['id']."'>Inactive</a>&nbsp;";
                        } ?>
                        </td>
                        <td><?php echo $row['created_at'] ?></td>
                        <td class="text-center">
                        <?php
                        echo "<a class='text-danger' href='?type=delete&id=".$row['id']."'><i class='fa fa-trash'></i></a>";
                        ?>
                        </td>
                    </tr>
                    <?php } ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
</div>
</body>
</html>