Bon, je ne sais pas si je suis débutant mais je vais tout de meme faire ma demande ici. 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 :
[table="width: 500"]
[tr]
[td]Nom de l'élève[/td]
[td]2019.01.01 Examen [/td]
[td]2019.01.02 Test[/td]
[td]2019.01.02 test[/td]
[/tr]
[tr]
[td]Jean[/td]
[td]15[/td]
[td]20[/td]
[td]20[/td]
[/tr]
[tr]
[td]Pierre[/td]
[td]18[/td]
[td]15[/td]
[td]15[/td]
[/tr]
[/table]
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 : Tout sélectionner
$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);Code : Tout sélectionner
$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>