mercredi 4 mars 2020

How can I use PHP to figure out which dynamically created checkboxes are marked. Then collect that data [duplicate]

enter image description here

For every "Select" box that is checked I need to find a way to save the information on the resulting line.

This is how I am thinking I can do it for one instance of multiple check boxes:

            <?php
        if(count($records) > 0 ):
          foreach($records as $record):
            ?>
            <tr>
              <td><input type="checkbox" name="member_check_list[]" value="<?php echo $record['ID'] ?>"></td>
              <td><?php echo $record['last_Name']; ?></td>
              <td><?php echo $record['first_Name']; ?></td>
              <td><input type="checkbox" name="member_check_list[]" value="<?php echo $record['ID'] ?>"></td>
              <td><input type="checkbox" name="member_check_list[]" value="<?php echo $record['ID'] ?>"></td>
              <td><input type="checkbox" name="member_check_list[]" value="<?php echo $record['ID'] ?>"></td>
            </tr>
            <?php
          endforeach;
        else:
          ?>
          <tr>
            <td colspan="6">  Cannot Find Any records.</td>
          </tr>
          <?php
          endif
          ?>

This will put them all into one array, would this be a solution? The way It looks in my head is that i may need two-dimensions to save all the data. I can use a unique name for each array for example I can rename "memeber_check_list[]" to : "<?php echo $record[first_Name]"?>_member_list[]". Would that work as a solution?

Their has got to be an easy way to do this these forms are online a dim a dozen.

If your reading this thanks for your time !




Aucun commentaire:

Enregistrer un commentaire