Insert updated rows in another table

Hi everyone! I would be greatfull if I find someone to help solve the issue bellow. I want to insert the updated rows in an other table . How can I proceed with the insertion query?
update is ok but insertion nothing being submitted

if(isset($_POST['hidden_id']))
{
 $customer = $_POST['customer'];
 $date = $_POST['date'];
 $payment_status = $_POST['payment_status'];
 $grand_total = $_POST['grand_total'];
 $reference_no = $_POST['reference_no'];
  $paid = $_POST['paid'];
 $id = $_POST['hidden_id'];
 for($count = 0; $count < count($id); $count++)
 {
  $data = array(
   ':customer'   => $customer[$count],
   ':date'  => $date[$count],
   ':payment_status'  => $payment_status[$count],
   ':grand_total' => $grand_total[$count],
   ':reference_no'   => $reference_no[$count],
    ':paid'   => $paid[$count],
   ':id'   => $id[$count]
  );
  $query = "
  UPDATE sales 
  SET customer = :customer, date = :date, payment_status = :payment_status, grand_total = :grand_total, reference_no = :reference_no, paid = :paid
  WHERE id = :id
  ";
  $query= "(insert into payments(date,paid) values (' $date',' $paid' ))";

  
  $statement = $connect->prepare($query);
  $statement->execute($data);
 }
}

Is this for logging, auditing, or what?

It is about sales update. I want anytime I update a sale , the posted values should update the sales and insert them in another table called payments

[astonecipher] thanks a lot , I solved the problem by myself

Even if you did solve this, the way it should be handled is a trigger on the table, not through code.

Sponsor our Newsletter | Privacy Policy | Terms of Service