<html>
<body>
<?php
$img='productimage';
$con=mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("agriculture", $con);
$qry="select product.productstock, product.name_category, product.nameseller, product.subcategory, product.name, product.productcode, product.price, product.productimage, product.status, order_detail.quantity FROM product
INNER JOIN order_detail on product.serial = order_detail.productid
";
while ($row=mysql_fetch_array($qry)){
$total=$row['productstock'];
$quantity=$row['quantity'];
$id=$row['serial'];
$newTotal=$total - $quantity;
$qry= "UPDATE product SET productstock = '$newTotal' WHERE serial='$id'";
?>
<table>
<tr>
<td align="center"><?php echo $row['name']; ?></td><br/>
<td align="center"><?php echo $row['price']; ?></td><br />
<td align="center"><?php echo $total = $row['productstock'] - $row['quantity']; ?></td> <br/>
</tr>
</tr>
</form>
<?php
}
echo "</table>";
mysql_close($con);
?>
</body></html>
this is my first post. my product stock cannot update when i buy the product. please help me this is my final project. i have only 2 days to complete it. I am having an issue trying update the database with my product.
I'm sorry if this hard to read etc. Also, I know there is security flaws in my GET/POST queries I'm just trying to get the thing to work before I start using the prepared statements or whatever they are called.
Use this
$qry= "UPDATE product SET productstock = '$newTotal' WHERE serial='$id'";
mysql_select_db('agriculture');
mysql_query( $qry, $con );
instead of this
$qry= "UPDATE product SET productstock = '$newTotal' WHERE serial='$id'";
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments