Advertisement
Guest User

Untitled

a guest
Dec 20th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. <?php
  2. // sample config
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "root";
  6. $dbname = "sample";
  7.  
  8. // Create connection
  9. $conn = new mysqli($servername, $username, $password, $dbname);
  10.  
  11. // Check connection
  12. if ($conn -> connect_error) {
  13. die("Connection failed: " . $conn -> connect_error);
  14. }
  15.  
  16. if (isset($_POST['submit'])) {
  17. $price = $_POST['price'];
  18. $quant = $_POST['quant'];
  19. $sub = $_POST['sub'];
  20.  
  21. foreach ($price as $key => $p) {
  22. $quantdb = $quant[$key];
  23. $subdb = $sub[$key];
  24.  
  25. $sql = "INSERT INTO table2 (price, quantity, subtotal) VALUES ('$p', '$quantdb', '$subdb')";
  26.  
  27. $conn->query($sql);
  28. }
  29. }
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement