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

后端 未结 6 1885
难免孤独
难免孤独 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条回答
  •  南方客
    南方客 (楼主)
    2020-12-22 14:31

    This would be your table design: (https://jsfiddle.net/vg3whzvq/2/)

    SeqNo Student Id maths art
    Exam 1 Exam 2 Exam 1 Exam 2
    1 200301 51 25 64 45

    Now to display the data with php you can do something like that:

    $output .= "";
    
              $studentCounter = 0;
    
    foreach($result as $item)
                {
                $output .= "";
                }
    
     $output .= "
    SeqNo Student Id maths art
    Exam 1 Exam 2 Exam 1 Exam 2
    " . ++$studentCounter . " " . $item[STUDENT_ID] . " " . $item[MATHS_EXAM_1] . " " . $item[MATH_EXAM_2] . " " . $item[ART_EXAM_1] . " " . $item[ART_EXAM_2] . "
    ";

    It now depends on how your $result looks like.

提交回复
热议问题