Check checkbox data that has variable names

Asked

Viewed 164 times

3

I have a routine in PHP that generates a list with ten to fifteen names, and along with each name generates a checkbox that should be checked if there is a missing work of that name, if there is no missing work the box is not checked, and at the end of the conference, the list is sent.

How to receive check box names that have not been checked, since the names of each check box is assigned to them through variables ?

Note that it is very easy to receive from a form the given of a checkbox when it has a fixed name, that I know how to do, note in the code below that the check box has no fixed names, the action "confereescala.php" has to receive the names of the unmarked check box.

<form name="" method="Post" action="confereescala.php">
            <ul>
            <?php
            //recebe de outra pagina o nome da equipe de hoje
            $nomeEquipe = $_post['equipe'];

                    // bloco faz a busca na tabela empregados procurando empregados que sejam da equipe que foi enviada
                    $sqa = "SELECT * FROM `empregados` WHERE (`equipe` = '".$nomeEquipe."')  ";
                    $sqb = mysql_query($sqa);
                    $num = mysql_num_rows($sqb);


                // faz o loop imprimindo na tela os nomes encontrados e os checkbox que sao da equipe encontrada
                //observe que cada check box recebe um nome diferente, que é dado pela variavel $empregadosdehoje['nome']
            while ($empregadosdehoje = mysql_fetch_array($sqb);){ ?>


                <li><a><input type="checkbox" size="8" name='<?php echo $empregadosdehoje['nome'] ; ?>'> <?php echo $empregadosdehoje['nome'] ; ?> </a></li>



            <?php } //fecha o while ?>
            <input class="button" type="submit" value="conferencia"/>
            </ul>
            </form>
  • In fact, the empty checkbox has no "pass" value. What you could do is in the following file compare what was marked with the register in the bank, then extract the ones that were not marked, understood?

  • You could also create an "Hidden input" together when creating checkboxes. Ai on the next page you get all Hidden, but then just compare with the checkbox. I find it easier this method.

  • 1

    Good afternoon Diego,, thanks for the tip,,,,

  • If you can mark my answer as accepted then thank you. Thank you.

1 answer

2

Would you create one input Hidden together at the time of creating the checkboxes. Ai on the next page you get all Hidden, but there just compare with the checkbox. I find this method easier.

 <input type="hidden" name="anexoDown" id = "anexoDown">

Browser other questions tagged

You are not signed in. Login or sign up in order to post.