samedi 24 août 2019

insert checkbox value into mysql database

i want to enrol the student and insert the student id into mysql database after i check and submit the checkbox value, but i already try so many ways but still cannot...

This is the php code <?php if (isset($_POST['submitxd'])) { foreach ($_POST['enrol'] as $items) { $insert = $link->query("INSERT INTO student_course(studentID) values ('$items')");} } ?>

This is the html code $result = $link->query("SELECT * FROM student WHERE programmeName = '$programme' AND intake = '$intake'"); `while ($row = mysqli_fetch_array($result)) {

echo "<tr>
                  <td>".$row['studentID']."</td>
                  <td>".$row['studentName']."</td>
                  <td>".$row['studentGender']."</td>
                  <td>".$row['studentContact']."</td>
                  <td>
                  <input type='checkbox' name='enrol[]' value='".$row['studentID']."'>
                  </td>                      
                  </tr>";
        }




Aucun commentaire:

Enregistrer un commentaire