Please I need your help, I am new to PHP and I need your help in inserting multiple select array into the database in the form of this.
This is what I want to achieve. My table has 3 columns (id, examno, results). I want results column to be inform of subjects grades, subjects grades.........depending on the numbers of subjects and grades users select (e.g English C6, Mathematics C6) all in one column results.

This is my html codes
<form action="insert.php">
<div class="form-group">
<label>Exam Number</label> 
<input type="text" class="form-control" name="examno" id="examno">

<table width="100%" cellpadding="0" cellspacing="0" border="0" class="table table-borderless" id="example">
                        <td width="12%"><label class="control-label">S/NO</label></td> 
                        <td width="53%"><label class="control-label">SUBJECTS</label></td> 
                        <td width="35%"><label class="control-label">GRADE</label></td>

                                   <select name="results[][subjects]" class="form-control" id="subject">
                                      <option value="" selected="selected">Select subject</option> 
                                      <option value="English">English</option> <option value="Mathematics">Mathematics</option>
                                     <select name="results[][grades]" class="form-control"> 
                                     <option value=""> Select</option> 
                                     <option value="A1">A1</option> 
                                     <option value="B2">B2</option> 
                                <input type="submit">

I have about 9 subjects and grades to be inserted into the results column.

This is my insert.php

$examno = mysqli_real_escape_string($conn, $_POST['examno']);
$qualification = $_POST['results'];
    if(count($qualification) > 0){
        $inserts = array();
        foreach($qualification as $key=>$value){
            $inserts[] =  "('".$examno."', '".$value['subjects']."', '".$value['grades']."')";
        if(count($inserts) > 0){
            $query = mysqli_query("INSERT INTO qualifications(examno, subjects, grades) VALUES " . implode(',', $inserts)");
        echo "success";
        echo "failed";

I received index undefined error for subjects and grades and nothing inserted into the database.

Please help me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.