Link with Delete & Status(active,Deactive)


THE UPPER PROJECT LINKS ARE


...LIKE THIS...
update view.php

<?php
include("connect.php");
?>
           <!DOCTYPE html>
           <html>

           <head>
            <title>view</title>
           </head>

             <body>
                   <table align="center" border="1">
               <thead>
                 <tr>
                <th>SL NO.</th>
                <th>NAME</th>
                <th>EMP_NO</th>
                <th>DEPARTMENT</th>
                <th>SALARY</th>
                <th>PHONE</th>
                <th>ADDRESS</th>
                <th>STATUS</th>
                <th>UPDATE</th>
                <th>DELETE</th>
                 </tr>
               </thead>

<?php
$sql="SELECT * FROM employee_info";
   $qry=mysqli_query($con,$sql);
     $sl=1;
       while($row=mysqli_fetch_array($qry))
        {
?>
              <tbody>
                <tr>
               <td><?php echo $sl; ?></td>
               <td><?php echo $row['emp_name']; ?></td>
               <td><?php echo $row['emp_no']; ?></td>
               <td><?php echo $row['emp_dept']; ?></td>
               <td><?php echo $row['emp_salary']; ?></td>
               <td><?php echo $row['emp_phone']; ?></td>
               <td><?php echo $row['emp_address']; ?></td>

                <?php 
                if($row['status']==0) {?>
                <td><a href="active.php?id=<?php echo $row['id'] ?>">active</a></td>
                <?php }
               
                else { ?>
                <td><a href="deactive.php?id=<?php echo $row['id'] ?>">deactive</a></td>
                <?php } ?>


             
               <td><a href="update.php?id=<?php echo $row['id'] ?>">update</a></td>
                <td><a href="delete.php?id=<?php echo $row['id'] ?>">delete</a></td>
               </tr>
                          <?php $sl++;
            } 
                              ?>
              </tbody>
                  </table>
           </body>
           </html>


save this active.php

<?php
include("connect.php");
$id=$_GET['id'];
$sql="UPDATE employee_info SET status='1' WHERE id='$id'";
$qry=mysqli_query($con,$sql);

header("Location:view.php");
?>

save this deactive.php

<?php
include("connect.php");
$id=$_GET['id'];
$sql="UPDATE employee_info SET status='0' WHERE id='$id'";
$qry=mysqli_query($con,$sql);

header("Location:view.php");
?>

save this delete.php

<?php
include("connect.php");
$id=$_GET['id'];
$sql="DELETE FROM employee_info WHERE id='$id'";
$qry=mysqli_query($con,$sql);

header("Location:view.php");
?>

Comments

Post a Comment