Mise en page tableau avec php

Par pege, il y a 10 ans


Bonjour,

J'ai un tableau qui j'affiche de la manière suivante:

<table class="reference" style="min-width:800px;"> <tbody> <tr> <th>Equipe</th> <th>Jour</th> <th>Début</th> <th>Fin</th> <th>Terrain</th> </tr> <?php foreach(get_trainings() as $training): ?> <tr> <td><?php echo $training->team; ?></td> <td><?php echo $training->day; ?></td> <td><?php echo $training->begin; ?></td> <td><?php echo $training->end; ?></td> <td><?php echo $training->court; ?></td> </tr> <?php endforeach; ?> </tbody> </table>

Pour que les utilisiateurs puissent mieux visioner le tableau, j'aimerais qu'il y'ai un <tr> vide chaques fois que $training->team change. Est-il possible?

Merci d'avance!

4 réponses

Alexandre #lbac, il y a 10 ans

C'est plus en CSS que tu devrais réaliser ça je pense ;)

pege, il y a 10 ans

Mais ca n'a pas vraiment avoir avec le css, parce que j'ai un foreach, donc je pense qu'il faut plus utiliser une fonction...:/

Blinkers, il y a 10 ans

Un truc du genre ;)

<?php foreach(get_trainings() as $training): if(isset($last_team) && $last_team != $training->team){ ?> <tr> <td colspan="5"></td> </tr> <?php } ?> <tr> <td><?php echo $training->team; ?></td> <td><?php echo $training->day; ?></td> <td><?php echo $training->begin; ?></td> <td><?php echo $training->end; ?></td> <td><?php echo $training->court; ?></td> </tr> <?php $last_team = $training->team; endforeach; ?>
pege, il y a 10 ans

C'est tout à fait ca, merci!!