Create table with PHP checking with before value and current value (Array)

后端 未结 6 1893
难免孤独
难免孤独 2020-12-22 13:56

This is my data table1. I want this table change to as a table2. I have to use PHP for this. I wrote the some code using foreach but that is not working properly. C

6条回答
  •  猫巷女王i
    2020-12-22 14:12

    Try this once i didn't check the output i am assuming array like follow

    array(
         [
          "STUDENT_ID" => "1", 
         'MATHS' => 
                 array( 
                     "EXAM_1" => 'test 1', 
                     "EXAM_2" => 'test2'), 
         'ART' => 
                 array( 
                     "EXAM_1" => 'test 1', 
                      "EXAM_2"=> 'test2')
          ],
         [
          "STUDENT_ID" => "2", 
         'MATHS' => 
                 array( 
                     "EXAM_1" => 'test 1', 
                     "EXAM_2" => 'test2'), 
         'ART' => 
                 array( 
                     "EXAM_1" => 'test 1', 
                      "EXAM_2"=> 'test2')
          ]
         );
    

    `

    $output .= "
          ";
    
         $studentCounter = 0;
    
         foreach($result as $item)
            {
            $output .= "";
                         "
    
            }
       $output .= "
    SeqNo Student Id maths art
    " . ++$studentCounter . " " . $item[STUDENT_ID] . " " . $item[MATHS][EXAM_1] . " " . $item[MATHS][EXAM_2] . " " . $item[ART][EXAM_1] . " " . $item[ART][EXAM_2] . "
    ";

提交回复
热议问题