If I input a number in stock field then click add stock the quantity should increase and update, same as substract.
code for adding item and initial quantity
<label for="item_code">Item Code</label>
<select name="code" id="code">
<?php
$query = "SELECT * FROM item_code";
$select_item_name = mysqli_query($connection, $query);
while ($row = mysqli_fetch_assoc($select_item_name)) {
$item_id = $row["item_id"];
$item_code = $row["item_code"];
echo "<option value='{$item_id}'>$item_code</option>";
}
?>
</select>
<br>
<label for="item_name">Item Name</label>
<input type="text" name="item_name"><br>
<label for="item_name">Add Initial Quantity</label>
<input type="number" name="quantity"><br>
<input type="submit" name="add_item" value="Add Item">
code for displaying the table
My delete function is working
if(isset($_GET['delete'])) {
$the_item_management_id = $_GET['delete'];
$query = "DELETE FROM item_management WHERE item_management_id = {$the_item_management_id}";
$delete_query = mysqli_query($connection, $query);
header("Location:inventory_management.php");
}
I'm trying this for add stock
if(isset($_GET['add_stock'])) {
$the_item_management_id = $_GET['add_stock'];
$stock = $_POST["stock"];
$query = "SELECT item_quantity + $stock AS item_quantity FROM item_management";
$result = mysqli_query($connection, $query);
}
this is my database table