Hello Anyone,
First and foremost I try to make it a point to thank someone for their help beforehand just in case I forget, so thank you in advance.
Now onto my question.
I am working on an inventory db for work. Here is what I am trying to do:
DB NAME: INVENTORY
DB TABLE: shortages
TABLE COLUMNS: inv_id, item_no, quantity, min_level, max_level
I am trying to get all of the inventory items that have a quantity that is lower than the minimum level to display on my page. Let me show you what I have tried doing.
First suggested solution:
$sql = mysql_query("SELECT *, (Min_Stock_Level - Quantity_onHand) FROM inventory WHERE quantity_onHand < Min_Stock_Level ORDER BY Item_No ASC ") ;
while ($row = mysql_fetch_array($sql)){
echo $row['Item_No'] . "<br>";
echo $row['min_level'] . "<br>";
echo $row['max_level'] . "<br>";
echo $row['quantity'] . "<br>";
}
This solution worked getting everything under the quantity on hand but there are a bunch of records that have obnoxious numbers over the maximum levels set. It shouldn't be doing that.
My next solution went something like:
$sql = ("SELECT * FROM shortages ORDER BY Item_No")
while ($row = mysql_fetch_array($sql)) {
$min = $row['min_levels'];
$max = $row['max_levels'];
$qty = $row['quantity'];
if($qty < $min) {
echo (insert results here);
}else{
echo (default msg);
}
}
What I was attempting to do there is store the database fields into a variable and use an if/else statement to do my comparison. You are probably laughing at me (highschool all over again) but that is all I could think of.
Please, please, please help me out, give me some suggestions. I'm learning here so please bare with me. My knowledge isn't very advanced but I catch on somewhat quickly.
Thanks again.