Patulong naman po dito sa activity ko sakit na po kasi ng ulo ko kakaisip kung anong gagawin pasensya na po newbie lang po ako.
ETO po yung code ko pakitingnan nalang po kung tama yung ginawa ko wala pa po akong code para sa "Out of Stock"
[CODE lang="php"]
<!DOCTYPE html>
<html>
<?php
include 'DBcon/connect3.php';
?>
<head>
<title>inventory</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<h1 style="text-align: center">Basic Inventory</h1>
</head>
<body>
<div class="container">
<form method="POST" action="">
<div class="form-group">
<label for="exampleInputEmail"><b>Item Name</b></label>
<input type="text" class="form-control" name="ITName" style="">
</div>
<div class="form-group">
<label for="exampleInputEmail"><b>Price</b></label>
<input type="text" class="form-control" name="Price">
</div>
<div class="form-group">
<label for="exampleInputEmail"><b>Qty</b></label>
<input type="text" class="form-control" name="qty">
</div>
<button type="submit" name="btnSubmit" class="btn btn-primary">Submit</button>
</form>
<?php
if(isset($_POST['btnSubmit']))
{
$ITName = $_POST['ITName'];
$Price = $_POST['Price'];
$qty = $_POST['qty'];
mysqli_query($con3,"INSERT INTO inventory(ItemName, Price, Qty) VALUES('$ITName', '$Price', '$qty')");
echo "<script>
alert('Save');
windows.location.href='inventory.php';
</script>";
}
?>
</div>
<div class="container">
<table class="table table-bordered" width="100%">
<thead>
<tr>
<th scope="col" class style="text-align: center">Action</th>
<th scope="col" class style="text-align: center">Item Name</th>
<th scope="col" class style="text-align: center">Price</th>
<th scope="col" class style="text-align: center">Qty</th>
<th scope="col" class style="text-align: center">STATUS</th>
</tr>
</thead>
<tbody>
<?php
$result = mysqli_query($con3,"SELECT * FROM inventory");
while ($row=mysqli_fetch_array($result))
{
echo "<tr>";
$id = $row['id'];
$ItemName = $row['ItemName'];
$FPrice = $row['Price'];
$FQty = $row['Qty'];
$status = $row['Status'];
$FQty_val = '50';
if ($FQty_val > $FQty) {
$status = "Low Stock";
}if ($FQty_val <= $FQty) {
$status = "Good";
}
echo "<td><a href='delete3.php?id=$id'><button class ='btn btn-danger'>Delete</button></a>
<a href='edit3.php?id=$id'><button class ='btn btn-primary'>Edit</button></a>
<a href='add.php?id=$id'><button class ='btn btn-success'>Add</button></a>
<a href='subtract.php?id=$id'><button class ='btn btn-info'>Subtract</button><a/></td>";
echo "<td>".$ItemName."</td>";
echo "<td>".$FPrice."</td>";
echo "<td>".$FQty."</td>";
echo "<td>".$status."</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js" integrity="sha384-q2kxQ16AaE6UbzuKqyBE9/u/KzioAlnx2maXQHiDX9d4/zp8Ok3f+M7DPm+Ib6IU" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.min.js" integrity="sha384-pQQkAEnwaBkjpqZ8RU1fF1AKtTcHJwFl3pblpTlHXybJjHpMYo79HY3hIi4NKxyj" crossorigin="anonymous"></script>
</html>[/CODE]
ETO po yung code ko pakitingnan nalang po kung tama yung ginawa ko wala pa po akong code para sa "Out of Stock"
[CODE lang="php"]
<!DOCTYPE html>
<html>
<?php
include 'DBcon/connect3.php';
?>
<head>
<title>inventory</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<h1 style="text-align: center">Basic Inventory</h1>
</head>
<body>
<div class="container">
<form method="POST" action="">
<div class="form-group">
<label for="exampleInputEmail"><b>Item Name</b></label>
<input type="text" class="form-control" name="ITName" style="">
</div>
<div class="form-group">
<label for="exampleInputEmail"><b>Price</b></label>
<input type="text" class="form-control" name="Price">
</div>
<div class="form-group">
<label for="exampleInputEmail"><b>Qty</b></label>
<input type="text" class="form-control" name="qty">
</div>
<button type="submit" name="btnSubmit" class="btn btn-primary">Submit</button>
</form>
<?php
if(isset($_POST['btnSubmit']))
{
$ITName = $_POST['ITName'];
$Price = $_POST['Price'];
$qty = $_POST['qty'];
mysqli_query($con3,"INSERT INTO inventory(ItemName, Price, Qty) VALUES('$ITName', '$Price', '$qty')");
echo "<script>
alert('Save');
windows.location.href='inventory.php';
</script>";
}
?>
</div>
<div class="container">
<table class="table table-bordered" width="100%">
<thead>
<tr>
<th scope="col" class style="text-align: center">Action</th>
<th scope="col" class style="text-align: center">Item Name</th>
<th scope="col" class style="text-align: center">Price</th>
<th scope="col" class style="text-align: center">Qty</th>
<th scope="col" class style="text-align: center">STATUS</th>
</tr>
</thead>
<tbody>
<?php
$result = mysqli_query($con3,"SELECT * FROM inventory");
while ($row=mysqli_fetch_array($result))
{
echo "<tr>";
$id = $row['id'];
$ItemName = $row['ItemName'];
$FPrice = $row['Price'];
$FQty = $row['Qty'];
$status = $row['Status'];
$FQty_val = '50';
if ($FQty_val > $FQty) {
$status = "Low Stock";
}if ($FQty_val <= $FQty) {
$status = "Good";
}
echo "<td><a href='delete3.php?id=$id'><button class ='btn btn-danger'>Delete</button></a>
<a href='edit3.php?id=$id'><button class ='btn btn-primary'>Edit</button></a>
<a href='add.php?id=$id'><button class ='btn btn-success'>Add</button></a>
<a href='subtract.php?id=$id'><button class ='btn btn-info'>Subtract</button><a/></td>";
echo "<td>".$ItemName."</td>";
echo "<td>".$FPrice."</td>";
echo "<td>".$FQty."</td>";
echo "<td>".$status."</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js" integrity="sha384-q2kxQ16AaE6UbzuKqyBE9/u/KzioAlnx2maXQHiDX9d4/zp8Ok3f+M7DPm+Ib6IU" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.min.js" integrity="sha384-pQQkAEnwaBkjpqZ8RU1fF1AKtTcHJwFl3pblpTlHXybJjHpMYo79HY3hIi4NKxyj" crossorigin="anonymous"></script>
</html>[/CODE]
Attachments
-
You do not have permission to view the full content of this post. Log in or register now.