1

Image of array which is coming like this.

I want to store all the studentId in one group

i have tried like this:

i am bit new with for/foreach loops.

if($_POST['action']=='startGdstudents')  {
parse_str($_POST['participantsForGd'], $participantsForGd);
$jobID  =   $participantsForGd['jobID'];                      // example: 85
$group  =   mysqli_real_escape_string($conn,$_POST['group']); // example: 2

foreach ($participantsForGd as $k => $v){
    foreach ($v['StudentId'] as $studentid => $student){
    $q = $conn->query("INSERT INTO r_job_groups (student_id,job_id,group_id) VALUES (".$student.",".$jobID.",".$group.") ");
}
}

My errors:

Warning: Illegal string offset 'StudentId' in /home2/amerytec/public_html/lc-latest/gdcontroller .php on line 171

Warning: Invalid argument supplied for foreach() in /home2/amerytec/public_html/lc-latest /gdcontroller.php on line 171

Warning: Invalid argument supplied for foreach() in /home2/amerytec/public_html/lc-latest /gdcontroller.php on line 171

jitendrapurohit
  • 9,435
  • 2
  • 28
  • 39
Mr world wide
  • 4,696
  • 7
  • 43
  • 97

0 Answers0