lundi 18 avril 2016

submit ID using multiple checkboxes in PHP HTML Mysql

I am using multiple HTML checkboxes to submit student attendance. The checkbox once clicked submit '1' and if not checked, will submit '0'. I am able to submit '1' when checked but cant submit '0'. Below is my code:

<?php
    $subcheck = (isset($_POST['subcheck'])) ? 1 : 0;
    $date = date("Y/m/d");
    foreach ( $student as $attendance ) {
              echo "<tr>";
              echo "<td>$attendance->id</td>";
                echo "<td>$attendance->name</td>";
                echo "<td>
                        $attendance->classroom_id
                      </td>";?>
                    <input type="hidden" name="date[]" value="<?php echo $date;?>" />

            <td><input type="checkbox" name="status[]" value="<?php echo $attendance->id;?>"></td> 
            <td><input type="text" name="reason[]" ></td>

      <?php
            }
            ?>
<tr>  
      <td colspan="2" align="center"><input type="submit" value="Save" name="submit"></td>




Aucun commentaire:

Enregistrer un commentaire