1
After a filter I have this form with the users and their services, what I am trying to do is send the information to delete the records with the parameters set in the form, in case it would be the User ID and the Service, then I will insert the ones with checked marked, that is, can be multiple records at the same time being sent.
This is my form:
My variables are like this in my form:
<input type="checkbox" name="Check[]" class="checkbox1" <?php if ($retorno >= 1) { echo "checked='checked'"; } ?> value="<?php echo $IdUsuario; ?>">
<input name="IdUsuario" type="hidden" value="<?php echo $IdUsuario; ?>" />
<input name="IdServico" type="hidden" value="<?php echo $IdServico; ?>" />
<input name="IdInterface" type="hidden" value="<?php echo $IdInterface; ?>" /
I need to run one loop
to an effect an exclusion of my BD
, but I have no way to make this loop, because I only get the variables from a form, there is some way to do it only with those variables?
The variables I get are these:
$IdUsuario = (isset($_POST['IdUsuario'])) ? $_POST['IdUsuario'] : '';
$IdServico = (isset($_POST['IdServico'])) ? $_POST['IdServico'] : '';
My exclusion code is like this:
$sql = "DELETE FROM `gasUsuarioServico` WHERE `IdUsuario` = :IdUsuario AND `IdServico` = :IdServico";
$stm = $conexao->prepare($sql);
$stm->bindValue(':IdUsuario', $IdUsuario, ':IdServico', $IdServico);
$retorno = $stm->execute();
I don’t understand, can you offer more details? Why can’t you use these variables in the loop?
– MagicHat
Hello @Magichat, this is exactly my difficulty, how to build a loop with variables.
– adventistapr
Let me try to understand the situation... From what I realize the data contained in the variables are unique(because they are ids), the loop performs an action repeatedly until a condition is satisfied, however in this case(apparently) you will not be able to perform the action more than once... So then I’m not understanding the need for the loop... Try to explain in more detail the operation of this process you want, e.g., where the values of these ids will come from(although you mentioned a form)... I mean, will be sent 1 user and service at a time?
– MagicHat