简体   繁体   中英

Problem in updating the value in database by adding value from a form to the existing value in a table column using php

我正在尝试构建一个离线计费软件,它允许用户添加新项目、更新价格和没有库存 ECT ....我在更新库存时遇到问题。我想检索没有的数据从表单中添加新库存并将其添加到该特定产品的现有库存值中。我尝试使用 sum() 函数,也尝试使用可变加法。没有用。

Looks like you need a simple UPDATE query to add a value to an existing field, like :

UPDATE stock_table s
SET s.value = s.value + ?
WHERE s.id = ?

You want to replace the first question mark with the new stock value received from your form, and the second one with the primary key of the stock item you want to update.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM