jeudi 26 novembre 2020

I want write a code where it insert a data to multiple rows

I want to store my selected status and inputted note along with their corresponding studentId to my "attendance" database, but I have no idea how to do it, here's my code below. Thanks in advance

 <table id="myTable">
          <tr class="header">
            <th style="width:10%;">Data ID</th>
            <th style="width:10%;">LRN</th>
            <th style="width:10%;">Name</th>
            <th style="width: 10%">Status</th>
            <th style="width: 10%">Note</th>
            <?php
                $conn = mysqli_connect("localhost", "root", "", "cbnhs_db");
                // Check connection
                if ($conn->connect_error) {
                die("Connection failed: " . $conn->connect_error);
                }
                
                $sql = "SELECT * FROM v_enrollment_minimal
                      WHERE sectionId = 7;";
                $select = mysqli_query($conn, $sql);
                $num_rows = mysqli_num_rows($select);
                
                
                  if ($num_rows > 0) {
            
                while ($rows = mysqli_fetch_array($select, MYSQLI_ASSOC)) {
                  $middleInitial = substr($rows['mName'], 0,1);
                    echo "<tr>";
                    echo "<td>" . $rows['studentId'] . "</td>";
                    echo "<td>" . $rows['lrn'] . "</td>";
                    echo "<td>" . $rows['lName'] .", ". $rows['fName'] ." " . $middleInitial .  ".</td>";
                    ?>
                    <form action="checkAttendance.php" method="POST">
                    <td>
                      <select name="status" id="cars">
                        <option value="PRESENT">Present</option>
                        <option value="ABSENT">Absent</option>
                        <option value="TARDY">Tardy</option>
                      </select>
                    </td>
                    <td>
                      <input type="text" name="note">
                    </td>
                  </form>
                    <?php
                    echo "</tr>";
                    
                }
            }
          
            echo "</table>";
            
                $conn->close();
            ?>
                          
            <center><input type="submit" name="save" value="SAVE" style="margin-top: 2%;"></center>
            </form>

That code would look like this




Aucun commentaire:

Enregistrer un commentaire