1
私はのユーザーの場合buys
product
のコードを持っています。ここでデータはstored in text files
です。MySQLの数値列セルの値を1つ減らす方法はありますか?
私の質問は、データがMySQLに格納されている場合、このをどのように解決するかです。
基本的にはupdate the cell
でsubtracting 1
としたいです。たとえば、quantity = 200
の場合は、quantity = 199
に更新します。
for($i = 0; $i < count($ajProducts) ; $i++) {
if ($sProductId == $ajProducts[$i]->id) {
//check if the value of the id is equal to the value in the array.
$ajProducts[$i]->quantity = $ajProducts[$i]->quantity-1;
//increase the quanity of the object by one if there is a match ;
}
}
私はこのような何かを開始しました:UPDATE products SET quantityInStock=-1 WHERE productCode=':productCode
が、それは0
cell
に更新します。
よう
quantityInStock = quantityInStock - 1
が質問を詳しく説明してください設定し、質問が複数のタグを必要とするようです。 –