cannot update quantity in stock on database php/mysql

Nurul Izzati hamid
<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.

Munish Kumar

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Stock Quantity not Updated after Placing Order in magento

From Dev

How to Update Stock Quantity Manually in Magento

From Dev

How to get the stock quantity of an article from woocommerce?

From Dev

Use of "FOR UPDATE" during Magento stock quantity update

From Dev

echo woocommerce stock quantity of a particular product id

From Dev

Get dates when quantity were out of stock

From Dev

PDO SQLite cannot update record: "database is locked"

From Dev

Update quantity session array

From Dev

How get variation's stock quantity woocommerce

From Dev

Magento - get item stock/quantity per site

From Dev

Prevent 'Add to cart' If quantity Exceeds than stock

From Dev

Prestashop - Cancelled order product quantity not increased in stock quantity

From Dev

Entity Framework cannot update database

From Dev

Updating in stock quantity based on shopping cart quantity in rails app?

From Dev

Displaying the 'out of stock' string on shop page but not the stock quantity.

From Dev

Query for update stock quantity in transaction

From Dev

laravel 5.8 cannot update value in database

From Dev

WooCommerce product variations: Auto enable Manage Stock and set stock quantity

From Dev

Cannot update SQL database

From Dev

Get dates when quantity were out of stock

From Dev

Cannot update SQL database from C#

From Dev

cannot update database without error

From Dev

How to update item quantity in excel?

From Dev

Prevent 'Add to cart' If quantity Exceeds than stock

From Dev

Prestashop - Cancelled order product quantity not increased in stock quantity

From Dev

I cannot update alphabetic password in database

From Dev

How To Show MessageBox if Quantity Textbox Value Greater Then Available Stock In Database

From Dev

Dynamic Table Quantity update Javascript

From Dev

update quantity with ajax

Related Related

  1. 1

    Stock Quantity not Updated after Placing Order in magento

  2. 2

    How to Update Stock Quantity Manually in Magento

  3. 3

    How to get the stock quantity of an article from woocommerce?

  4. 4

    Use of "FOR UPDATE" during Magento stock quantity update

  5. 5

    echo woocommerce stock quantity of a particular product id

  6. 6

    Get dates when quantity were out of stock

  7. 7

    PDO SQLite cannot update record: "database is locked"

  8. 8

    Update quantity session array

  9. 9

    How get variation's stock quantity woocommerce

  10. 10

    Magento - get item stock/quantity per site

  11. 11

    Prevent 'Add to cart' If quantity Exceeds than stock

  12. 12

    Prestashop - Cancelled order product quantity not increased in stock quantity

  13. 13

    Entity Framework cannot update database

  14. 14

    Updating in stock quantity based on shopping cart quantity in rails app?

  15. 15

    Displaying the 'out of stock' string on shop page but not the stock quantity.

  16. 16

    Query for update stock quantity in transaction

  17. 17

    laravel 5.8 cannot update value in database

  18. 18

    WooCommerce product variations: Auto enable Manage Stock and set stock quantity

  19. 19

    Cannot update SQL database

  20. 20

    Get dates when quantity were out of stock

  21. 21

    Cannot update SQL database from C#

  22. 22

    cannot update database without error

  23. 23

    How to update item quantity in excel?

  24. 24

    Prevent 'Add to cart' If quantity Exceeds than stock

  25. 25

    Prestashop - Cancelled order product quantity not increased in stock quantity

  26. 26

    I cannot update alphabetic password in database

  27. 27

    How To Show MessageBox if Quantity Textbox Value Greater Then Available Stock In Database

  28. 28

    Dynamic Table Quantity update Javascript

  29. 29

    update quantity with ajax

HotTag

Archive