add user balance from login user list from online database or how to deduct balance mysqli_query.

When we submit a form, then we have to debit money or rupees from the user’s balance with data insert or sometimes it has to be done, we also have to maintain the balance with insert query or update query so how can

Insert query with balance add or minus in database table in sql

inlucde("connection.php");                                                           $query="INSERT INTO `formdatatable` (`id`, `userid`, `fullname`,  `address`, `created_time`) VALUES (NULL, '8867676786Xx', 'naresh sir', 'dausa, rajasthan,india','2022-01-09 16:46:00');";                                                                                                 $data = mysqli_query($connection,$query);                             if ($data==TRUE) {                                      $sql = "update login_user SET balance = balance - 10 where userid='8867676786Xx'";                                      $abs = mysqli_query($connection, $sql);             ?>
HTML

Update query with balance add or minus in database table in sql

inlucde("connection.php");                                                           $query="UPDATE `formdatatable` SET `fullname` = 'naresh raj' WHERE `formdatatable`.`userid` = '8867676786Xx'; ";                                                                                                                                         $data = mysqli_query($connection,$query);                                                                             if ($data==TRUE) { $sql = "update login_user SET balance = balance + 20 where userid='8867676786Xx'";  $abs = mysqli_query($connection, $sql);             
if($abs ==TRUE){
 echo "Update Successfully"; 
}else{
 echo "Not Update"; }?>
HTML

 

Leave a Reply

Your email address will not be published. Required fields are marked *