I have trouble using the output of one query as a value in another. The thing is I need to get the price of one product (which is successfully accomplished) using the following query:
SELECT Cena FROM Proizvod WHERE ProzivodID = $PID
$PID is a PHP variable and this query works just fine. The problem comes when I want to subtract the price of the product from the buyer’s balance.
I tried to do that with the following query:
UPDATE Kupuvac SET Saldo = Saldo - ".$cena." WHERE KupuvacID=$KID
$cena is a PHP variable, the value of which is the first query.
The second query doesn’t work at all, it doesn’t return an error message, but it doesn’t change he buyer’s balance.
A short dictionary if someone needs it: Cena - Price; Proizvod - Product; Kupuvac - Buyer; Saldo - Balance.
Thanks in advance!
You can do your
UPDATEoperation in one statement: