Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="container">
- <form method="POST" id="order_form" action="action.php">
- <table id="Order_from_wards" class="table table-striped table-bordered">
- <thead>
- <th>Item ID</th>
- <th>Item Name</th>
- <th>Suggest Qty</th>
- <th>Chosen Quantity</th>
- </thead>
- <tbody>
- <?php
- include("config.php"); //Includes data connection information
- $result = mysqli_query($conn, "SELECT ItemID, ItemName, suggQTY FROM `TABLE 48` WHERE var1 = 'cond1' AND var2='cond2'");
- while ($row = mysqli_fetch_assoc($result)):
- ?>
- <tr>
- <td><input type="text" name="ItemID[]" form="order_form" value="<?php echo $row['ItemID']; ?>"></td>
- <td><input type="text" name="ItemName[]" id ="order_form" form="order_form" value="<?php echo $row['ItemName']; ?>"></td>
- <td><input type="number" name="suggQTY[]" form="order_form" value="<?php echo $row['suggQTY']; ?>"></td>
- <td><input type="number" name="orderQTY[]" form="order_form" value="<?php echo $row['suggQTY']; ?>"></td>
- <?php endwhile; ?>
- </tbody>
- </table>
- <input name="submit" type="submit" form="order_form" data-submit="...Sending"/>
- </form>
- </div>
- <?php
- $ItemID = $_POST['ItemID[]'];
- $ItemName = $_POST['ItemName[]'];
- $suggQTY = $_POST['suggQTY[]'];
- $orderQTY = $_POST['orderQTY[]'];
- $host = "host";
- $dbusername = "username";
- $dbpassword = "password";
- $dbname = "dbname";
- $conn = new mysqli($host, $dbusername, $dbpassword, $dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- for ($i=0; $i <= sizeof($item_ID[]); $i++) {
- $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')";
- if ($conn->query($INSERTstock) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement