0
Pls help me..Any given idea is welcome.
Am been working on this project. I created a table called drugs & created another table called orders... Now i have like quantity as a column in my drugs table.. In orders table how can someone makes an order of a drug so it should subtract it from the qauntity column of the drug table... E.g Drugs table.... Has a column named quantity... We have quantity as 5... The how can one makes 1 order so it should subtract it from 5 to remainder 4 to be left in quantity... Pls any observation thanks for listening.
5 Réponses
+ 1
the only way to decrease quantity is to update:
$result = $conn->query("select quantity from drugs where columnname = columnvalue ");
if($row = $result->fetch_assoc()){
$newqty = $row['quantity'] - 1;
$query = "update drugs set quantity = $newqty where columnname = columnvalue ";
if( $conn->query($query)){
echo "updated";
}else{
echo "fail to updated";
}
}
+ 2
What are you using this in? php or js?
0
Coder's Crux is php
0
Well then, you can simply run a query to the table called drugs, using mysqli_query() and then run a query to deduct the quantity of drugs from the current stock.
EDIT: Also, what use is the drugs table? Do you have multiple rows with different types of drugs in them?
0
Soo Zhan Nam Thank you