简体   繁体   中英

Increase a value like = +1 in mysql and PHP

I need help with this.

I am making a login and when a user insert a bad answer i want that my system take the valor of the column in the database and this adds the value of the base + 1

I try making this

$sql2 = "UPDATE usuarios_empleados  set intentos = + 1 where usuario = ?";
$params2 = array ($this->nickname);
return Database::executeRow($sql2, $params2);

请尝试此行,希望它能工作

"UPDATE usuarios_empleados SET intentos = intentos + 1 where id_usuario_empleado = your_value"

更新usuarios_empleados设置intentos =(intentos +1)其中usuario =吗?

You have to first make a SELECT and see the value of the column "intentos". Then you will do the UPDATE using the value from the SELECT + 1

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