Increment my variable in a database with UPDATE in PHP

后端 未结 2 2048
花落未央
花落未央 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:44

    You can use like this for variable in text query.

    $req= ("UPDATE ingredients SET stock='".($stock+1)."' WHERE nom = :nom;");
    

提交回复
热议问题