Increment my variable in a database with UPDATE in PHP

后端 未结 2 2046
花落未央
花落未央 2021-01-29 06:24

I get the variable \'stock\' from my database. I would like increment my variable with an update with this code:

$stock = $_POST[\'stock\']

$nom = \'salade\';
$         


        
2条回答
  •  抹茶落季
    2021-01-29 06:35

    Considering that you're saying all you need to is increment by 1 each row WHERE nom = :nom (I guess your actual code isn't wrong with $ instead of : or it wouldn't even "increment by 8" as you said you're already achieving... remember do edit this on your question, please):

    UPDATE
        ingredients
    SET
        stock=stock+1
    WHERE
        nom = :nom;
    

    Jusk pick what you already had and add 1 stock=stock+1.

提交回复
热议问题