Selector does not work

0

Good afternoon, I have a table where I have a record selector checkbox. I want to select some records to change the value of a variable common to all of them but I have no way to pass those values by POST. Everything goes through a modal but I would not mind skipping the modal and it would work directly

                <form action="" method="post" enctype="multipart/form-data">
                <table data-toggle="table" width="auto"  data-show-refresh="true" data-show-toggle="true" data-show-columns="true" data-search="true" data-select-item-name="toolbar1" data-pagination="true" data-sort-name="date" data-sort-order="desc">
                <div class="pull-right">
                            <ul class="nav nav-pills">
                            <li class="">
                                <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">Add lesson</button>
                            </li>
                            <li class="">
                                <a data-toggle="modal" href="#teacher_payments" id="delete" class="btn btn-info" name="">Paid selected lessons</a>
                            </li>    
                            <li class="">
                                <a href="teachers.php" class="btn btn-danger">Back</a>    
                            </li>    
                            </ul>
                </div>
                <br><br><br>
                    <thead>
                        <tr>
                            <th>Lesson</th>
                        <!--<th>Teacher</th>-->
                            <th>Student</th>
                            <th align="center">Date</th>
                            <th align="left">Start</th>
                            <th data-field="state" data-checkbox="true"></th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php $query = mysql_query("select * from teacher_class
                            LEFT JOIN class ON class.class_id = teacher_class.class_id
                            LEFT JOIN subject ON subject.subject_id = teacher_class.subject_id
                            LEFT JOIN student ON student.student_id = teacher_class.student_id
                            where teacher_id = '$get_id' order by date DESC")or die(mysql_error());


                            while($row = mysql_fetch_array($query)){
                                    $id = $row['teacher_class_id'];
                    ?>
                        <tr>                                    
                            <td valign="middle"><?php echo $row['class_name']; ?></td>
                        <!--<td><?php //echo $row['teacher_id']; ?></td>-->
                            <td><?php echo "<a data-toggle=\"modal\" href='exams.php?id=$student_id'>$name $lastn</a>";?></td>
                            <td><?php echo date("d/m/Y",strtotime($row['date'])); ?></td>
                            <td>
                                <input id="optionsCheckbox" name="selector[]" type="checkbox" value="<?php echo $id; ?>">
                            </td>
                        <?php } ?>
                        </tr>
                    </tbody>
                </table>
                </form>

    <!-- /.modal -->

    <!-- Modal -->
    <div class="modal fade" id="teacher_payments" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header" style="background-color:#333">
                <form name="form2" role="form" method="post" enctype="multipart/form-data">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 id="myModalLabel">Add Lesson</h4>
                </div>
                <div class="modal-body" style="background-color:#111">
                <input class="form-control" name="firstname"  id="proposalId1" type="text" placeholder = "Firstname">
                    <label>Lastname:</label>
                </div>
                <div class="modal-footer" style="background-color:#111">
                    <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                    <button name="switch" class="btn btn-primary">Yes</button>
                </form>
                </div>
            </div>
        </div>
    </div> 
    <!-- /.modal -->


<?php
if (isset($_POST['switch'])){
$id=$_POST['selector'];
$N = count($id);
for($i=0; $i < $N; $i++)
{

    $result = mysql_query("update teacher_class set paymentstatus = 'Paid' where teacher_class_id = '$id[$i]'");
}
?>
<script>
    window.location = "teacher_class_control.php?id=<?php echo $get_id; ?>";
</script>
<?php }  ?>
    
asked by Vieira 06.10.2017 в 16:32
source

0 answers