🔒 Closed Patulong po sa mga PHP expert dyan

Status
Not open for further replies.

GenShiN

Fanatic
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.

Inventory.png

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]
 
salamat po ng marami sir napagana ko na po....kelangan pala dalawang equal sign yung una ko kasing ginawa isang equal sign lang kaya nagiging 0 lahat ng value nung Qty ko....salamat po ulet sir...
 
if ($FQty_val > $FQty) {
$status = "Low Stock";


}if ($FQty_val <= $FQty) {
$status = "Good";


}

pag continous if statement lodi dapat else if ilagay mo....

if ($FQty_val > $FQty) {
$status = "Low Stock";


}else if ($FQty_val <= $FQty) {
$status = "Good";


}else if($FQty_val === 0){
$status = "Out of stock";
}
 
Status
Not open for further replies.

About this Thread

  • 7
    Replies
  • 515
    Views
  • 3
    Participants
Last reply from:
F A L L E N

Trending Topics

Online now

Members online
1,083
Guests online
3,198
Total visitors
4,281

Forum statistics

Threads
2,307,594
Posts
29,179,856
Members
1,192,526
Latest member
NesMilo
Back
Top