I have a field that stores a numeric value that will go from 0 to 7. It is a counter for some steps to be completed in the application. Each time a step is completed, the counter is updated with the new value. User can go back on the steps and then forward. If he has completed step 3, he can go back to step 1 and then forward till step 3 again. What I want to do is to avoid that when the user returns to step 3 the counter gets updated with 1 and 2 values but remains 3. I want to investigate a way to do it within the update query.
The query is the following:
try{
$pdo->query("UPDATE ruolo SET wiz_step='$step' WHERE id_user='$utente'");
}
catch(PDOException $e){
$status='500';
$data['step']=$step;
$message='Si è verificato un errore. Abbiamo aperto una segnalazione al team tecnico.';
}
$message="Step aggiornato correttamente";
}
Is it possible to tell mysql to update wiz_step only if $step is > than the value of wiz_step before the update?
Table structure is just made of three int fields: id primary and autoincrement, id_user and wiz_step. Note: I assume I am not open to mysql injections since none of the values in the query are coming from a user input. They are all set by the php logic.