Your Location is: Home > Php

PHP table rows based on table header

From: Singapore View: 3048 george 


i want to create a table of all classes as table header and rows with name of student in each class each column according to it header, all data come from two (students, classes) mx code :

    <thead >
     foreach ($groupList as $group):
     <th><?= $group['group_name'] ?></th>
<?php endforeach; ?>
          foreach ($groupList as $group) {
              echo '<td>' ;
              foreach ($db->getStudentsByGroup($group['u_id']) as $name){
                 echo  $name['fname'] ;
              echo '</td>';

this code shows them grouped as wanted but all names are in the same row as below

group1            group2
tom, sam, bob,    x, y ,...
mark, ...

, i tried to change the location of the (td, tr) but no success, any idea how to do it properly , thanks in advance

Best answer