How to Make Active or Inactive in PHP With Mysql Database


<?php
mysql_connect('localhost','root','');
mysql_select_db('database');
if(!empty($_GET['status_id'])&&isset($_GET['status_id']))
  {
   $status_id = $_GET['status_id'];
   $status = $_GET['status'];
   $query = "update menus set status = '$status' where id = '$status_id'";
   mysql_query($query);
   header("location:menus.php");
  }
 // Active / De-Active Record
?>
<html>
<head>
<title>Active/Deactive</title>
</head>
<body>
<form method="POST">
<table border="1">
   <?php 
    
    $query = "select * from table";
    $result = mysql_query($query); 
    
    $row = mysql_fetch_assoc($result)
   ?>
   
   <tr> 
    
   <th>Items db</th>
    <?php
     $status =  $row['status']; 
     if($status == 1): 
    ?>
    <td style="text-align:center;">
     <a href="menus.php?status_id=<?php echo $row['id'];?>&status=0">
      <img src="ok.png" title="Active / Deactivate Record" />
     </a>
    </td>
    <?php else: ?>
    <td style="text-align:center;">
     <a href="menus.php?status_id=<?php echo $row['id'];?>&status=1">
      <img src="cross.png" title="Active / Deactivate Record" />
     </a>
    </td>
    <?php endif; ?>
    </tr>
</table>
</form>
</body>
</hrml>
Read full Post

Comments

Popular posts from this blog

Student Result Management System

What Is The Job Role Of A Customer Support Executive?

TOP RECRUITMENT COMPANIES IN INDIA