It is necessary to build on the basis of two SQL tables one common table Statement. The first sets the number and names of columns with disciplines. The second stores data about students and their assessments. Each evaluation record by discipline is unique. The problem is to display the records of the second table in the required format, so that in the disciplines for which the assessment is given the value of the assessment is derived, and for the disciplines that are not set, nothing.
Tell me how to organize the output so that at these positions instead of Array the values of $ columns [$ i] [$ j] ['record_id'] and $ columns [$ i] [$ j] ['record_mark'] are output?
Code:
for ($i=0; $i < $studentsLength; $i++) { $columns[$i] = []; for ($k=0; $k < $recordsLength; $k++) { for ($j=0; $j < $disciplinesLength; $j++) { if ($records[$k]->Discipline_ID == $disciplines[$j]->id && $records[$k]->Student == $students[$i]->StudentName) { $columns[$i][$j]['record_id'] = $records[$k]->id; $columns[$i][$j]['record_mark'] = $records[$k]->Mark; } } } print "<tr> <td>{$students[$i]->StudentName}</td>"; for ($l=0; $l < $disciplinesLength; $l++) { //print_r($columns[$i]); if (in_array($l, $columns[$i])) { print "<td>{$columns[$i][$l]}</td>"; } else { print "<td></td>"; } } print "</tr>"; 