puremindquietheart

benjie php eto

Aug 10th, 2018
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1.  
  2. <?php
  3. include 'includes/session.php';
  4.  
  5. $po_ID = $_POST['po_ID'];
  6.  
  7. $json = $_POST['items'];
  8.  
  9. $client_id = $_POST['client_id'];
  10.  
  11. $date_reserve = date('Y-m-d');
  12.  
  13. $conn = $pdo->open();
  14.  
  15. foreach ($json as $key => $value)
  16. {
  17. for ($i = 1; $i <= $value["quantity"]; $i++)
  18. {
  19. //echo "Model:". $value["model"]. "<br>". "Client ID:". $client_id. "<br>". "PO ID:". $po_ID. "<br>";
  20.  
  21. try
  22. {
  23. $stmt = $conn->prepare("INSERT INTO backup_sales (po_ID, model_id, client_id, sales_date)
  24. VALUES (:po_ID, :model_id, :client_id, :sales_date)");
  25.  
  26. $stmt->execute(['po_ID'=>$po_ID, 'model_id'=>$value["model"], 'client_id'=>$client_id, 'sales_date'=>$date_reserve]);
  27.  
  28. $_SESSION['success'] = "<b>".$po_ID."</b> Edit reserved quantity successfully";
  29. }
  30. catch(PDOException $e){
  31. $_SESSION['error'] = $e->getMessage();
  32. }
  33. }
  34. }
  35.  
  36. $pdo->close();
  37.  
  38. ?>
Add Comment
Please, Sign In to add comment