php - Submit data in a textbox from a while loop to database -


i need enter scores subjects offered students in class simultaneously. retrieved students id, retrieved list of subjects being offered students, , placed textbox under each subject.

now, want submit score in database subject name , student id, score not storing, subject name , student id.

here code:

<form method="post">   <?php     include "includes/dbcon.php";     $subject_name ="";     echo "<table border='1'><thead><tr><td>students name</td>";     $query_subjects = mysqli_query($link,"select * junior_subjects order subject_name asc");     while ($row_subject=mysqli_fetch_array($query_subjects))     {       $subject_name .= $row_subject['subject_name'];       echo "<td>".$row_subject['subject_name']."</td>";     }     echo "</tr></thead>";     $query_students = mysqli_query($link,"select * students class_cat='junior'");     while ($row_students=mysqli_fetch_array($query_students))     {       $student_id = $row_students['student_id'];       echo "<tr><td>".$row_students['student_id']."</td>";       $query_subjects2 = mysqli_query($link,"select * junior_subjects order subject_name asc");       while ($row_subject2 =mysqli_fetch_array($query_subjects2))       {         $subject_name2 =$row_subject2['subject_name'];         echo "<td>                 <input type='text' hidden name='$subject_name2'>                 <input type='text' size='4' name='$subject_name2'>               </td>";         /////         if (isset($_post['submit']))         {           $score = $_post[$subject_name2];           mysqli_query($link,"insert score_sheet(student_id,subject_name,score) values('$student_id','$subject_name2','$score') ");         }       }     }      ?>   <input type='submit' name='submit'> </form> 

you should have input score array , make foreach loop insert query.

you should have input field this

and foreach loop this

    $score = $_post['score'];     foreach ($score $key)      {     $query = "insert score_sheet(student_id,subject_name,score) values('$student_id','$subject_name2','$key') ";        $query = mysqli_query($link,$query);         } 

note :

you should not have have 2 forms inside it.

i have made eval you

warning :

it not @ practise have such bulk entry.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -