Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. <div class="container">
  2. <form method="POST" id="order_form" action="action.php">
  3.  
  4. <table id="Order_from_wards" class="table table-striped table-bordered">
  5. <thead>
  6. <th>Item ID</th>
  7. <th>Item Name</th>
  8. <th>Suggest Qty</th>
  9. <th>Chosen Quantity</th>
  10. </thead>
  11. <tbody>
  12.  
  13. <?php
  14. include("config.php"); //Includes data connection information
  15. $result = mysqli_query($conn, "SELECT ItemID, ItemName, suggQTY FROM `TABLE 48` WHERE var1 = 'cond1' AND var2='cond2'");
  16. while ($row = mysqli_fetch_assoc($result)):
  17. ?>
  18.  
  19. <tr>
  20. <td><input type="text" name="ItemID[]" form="order_form" value="<?php echo $row['ItemID']; ?>"></td>
  21.  
  22. <td><input type="text" name="ItemName[]" id ="order_form" form="order_form" value="<?php echo $row['ItemName']; ?>"></td>
  23.  
  24. <td><input type="number" name="suggQTY[]" form="order_form" value="<?php echo $row['suggQTY']; ?>"></td>
  25.  
  26. <td><input type="number" name="orderQTY[]" form="order_form" value="<?php echo $row['suggQTY']; ?>"></td>
  27.  
  28. <?php endwhile; ?>
  29. </tbody>
  30.  
  31. </table>
  32. <input name="submit" type="submit" form="order_form" data-submit="...Sending"/>
  33. </form>
  34. </div>
  35.  
  36. <?php
  37. $ItemID = $_POST['ItemID[]'];
  38. $ItemName = $_POST['ItemName[]'];
  39. $suggQTY = $_POST['suggQTY[]'];
  40. $orderQTY = $_POST['orderQTY[]'];
  41.  
  42.  
  43. $host = "host";
  44. $dbusername = "username";
  45. $dbpassword = "password";
  46. $dbname = "dbname";
  47.  
  48. $conn = new mysqli($host, $dbusername, $dbpassword, $dbname);
  49. if ($conn->connect_error) {
  50. die("Connection failed: " . $conn->connect_error);
  51. }
  52.  
  53.  
  54.  
  55. for ($i=0; $i <= sizeof($item_ID[]); $i++) {
  56. $sql="INSERT INTO `TABLE 48` (WardID, ItemID, ItemName, suggQTY, orderQTY, order_date, status) VALUES ('mch', '$ItemID[$i]', $ItemName[$i]', '$suggQTY[$i]','$orderQTY[$i]',CURRENT_TIMESTAMP(),'ordered')";
  57. if ($conn->query($INSERTstock) === TRUE) {
  58. echo "New record created successfully";
  59. } else {
  60. echo "Error: " . $sql . "<br>" . $conn->error;
  61. }
  62. }
  63. $conn->close();
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement