tableau résultat en colonne
Bonjour,
je cherche à faire un tableau avec des résultats en colonnes, présentant les notes des élèves pour une matière.
La première colonne montre le nom des élèves
puis pour chaque contrôle, il y a une note par colonne. Cela donne :
Nom de l'élève |
2019.01.01 Examen |
2019.01.02 Test |
2019.01.02 test |
Jean |
15 |
20 |
20 |
Pierre |
18 |
15 |
15 |
J'ai réussi ma requête, Mais je n'arrive pas à faire mon titre "datecode" qui est la date + le type de test.
Ma requete fonctionnante :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| $sql = "SELECT CONCAT(t.date,'<br>', w.name) as datecode, CONCAT(s.firstname,' ', s.name) as student, l.niveau, t.code as code
FROM testline l, test t, registration r, entry e, student s, worktype w
WHERE t.code=l.test AND
w.code = t.worktype AND
t.year=r.year AND
t.semester=r.semester AND
t.classe=r.classe AND
l.student=r.student AND
e.registration=r.code AND
t.course=e.course AND
s.code=l.student AND
t.year='2019' AND
t.semester='1 Semestre' AND
t.classe = '2' AND
t.course= 'Biologie'
order by t.code";
$result=mysql_query($sql);
$dates = array();
$niveauEs = array();
$result=mysql_query($sql); |
Maintenant mon erreur est ici, Je n'ai en titre qu'un code, mais je voudrais "datecode" , Pouver vous m'aider s'il vous plait ?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| $data = array();
$dates = array();
while ($row=mysql_fetch_array($result))
{ // fetching result
if(!isset($data[$row['student']]))
{
$data[$row['student']] = array();
}
if(!isset($data[$row['student']][$row['code']]))
{
$data[$row['student']][$row['code']] = array();
}
if(!in_array($row['code'], $dates))
{
$dates[] = $row['code'];
}
$data[$row['student']][$row['code']] = $row['niveau'];
}
?>
<table width="80%" border="2" align="center" class="table-style-two">
<thead>
<th width="80px">Schüler</th>
<?php foreach($dates AS $date) : ?>
<th width="50px"><?=$date?></th>
<?php endforeach; ?>
</thead>
<tbody>
<?php foreach($data AS $student => $entries) : ?>
<tr>
<td><?=$student?></td>
<?php foreach($dates AS $date) : ?>
<td><?=(isset($data[$student][$date])?$data[$student][$date]:'')?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table> |
Une petite aide serait sympa....