how to set active and inactive in php using mysql ajax example?

Today, We want to share with you status active inactive php example.In this post we will show you Active And Inactive Users Concept Using Php And Ajax, hear for activate and deactivate concept using php and mysql ajax we will give you demo and example for implement.In this post, we will learn about Bootstrap Toggle Switch Update Database Field Using Ajax with an example.

how to set active and inactive in php using ajax?

Database

CREATE TABLE IF NOT EXISTS `product` (
`id` int(11) NOT NULL,
  `name` varchar(150) NOT NULL,
  `pcode` varchar(150) NOT NULL,
  `address` varchar(100) NOT NULL,
  `status` enum('0','1') NOT NULL DEFAULT '0'
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;

Html & PHP Code




  
  query("Select * from product");
        foreach ($sql as $key => $product) {
  ?>
  
# name pcode Action

Ajax Code



Ajax.php

real_escape_string($id);
$status=$db->real_escape_string($status);
$sql=$db->query("UPDATE product SET status='$status' WHERE id='$id'");
echo 1;
?>

CSS CODE

.btn-success {
   background-color: #65B688;
   border-color: #65B688;
   }
   .btn-danger {
   color: #fff;
   background-color: #d9534f;
   border-color: #d43f3a;
   }
   .btn {
   color: white;
   display: inline-block;
   margin-bottom: 0;
   font-weight: 400;
   text-align: center;
   vertical-align: middle;
   cursor: pointer;
   background-image: none;
   border: 1px solid transparent;
   white-space: nowrap;
   padding: 6px 12px;
   font-size: 14px;
   line-height: 1.42857143;
   border-radius: 4px;
   -webkit-user-select: none;
   -moz-user-select: none;
   -ms-user-select: none;
   user-select: none;
   }

I hope you get an idea about Active inactive users in PHP MySQLi.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment