Faire une boucle While dans un tableau
Résolu
crashay974
Messages postés
51
Date d'inscription
Statut
Membre
Dernière intervention
-
crashay974 Messages postés 51 Date d'inscription Statut Membre Dernière intervention - 10 juil. 2011 à 07:51
crashay974 Messages postés 51 Date d'inscription Statut Membre Dernière intervention - 10 juil. 2011 à 07:51
A voir également:
- Faire une boucle While dans un tableau
- Tableau word - Guide
- Tableau ascii - Guide
- Trier un tableau excel - Guide
- Comment faire un tableau croisé dynamique - Guide
- Comment imprimer un tableau excel sur une seule page - Guide
4 réponses
Saut, peut être ça ...
Pas sure du résultat, mais bon !!!
Pas sure du résultat, mais bon !!!
<table width="700px" cellpadding="0" cellspacing="5"> <?php $i=0; $colonne = 3; // Nombre de colonnes !!! while($file = readdir($dir)) { if($i == 0) echo '<tr>'; if($file != '.' && $file != '..' && !is_dir($dirname.$file) && $i<$colonne) { echo '<td width="51" td align="center" valign="top"> <div class="box"><br /> <a href="'.$dirname.$file.'" rel="lightbox[roadtrip]"> <img width="100" height="100" src="'.$dirname.$file.'"> </a><br /> <input type="radio" name="ch" value="'.$file.'"> </div> </td>'; $i++; } elseif($i == $colonne) { echo '<td width="51" td align="center" valign="top"> <div class="box"><br /> <a href="'.$dirname.$file.'" rel="lightbox[roadtrip]"> <img width="100" height="100" src="'.$dirname.$file.'"> </a><br /> <input type="radio" name="ch" value="'.$file.'"> </div> </td>'; echo '</tr>'; $i = 0; } } if($i != $colonne) { echo '<td width="51" td align="center" valign="top"> <div class="box"><br /> <a href="'.$dirname.$file.'" rel="lightbox[roadtrip]"> <img width="100" height="100" src="'.$dirname.$file.'"> </a><br /> <input type="radio" name="ch" value="'.$file.'"> </div> </td>'; echo '</tr>'; } ?> </table>
Bonjour,
pour passer à la ligne il faut imbriquer la balise <tr>
pour passer à la ligne il faut imbriquer la balise <tr>
<table width="700px" cellpadding="0" cellspacing="5"><?php while($file = readdir($dir)) { if($file != '.' && $file != '..' && !is_dir($dirname.$file)) { echo '<tr><td width="51" td align="center" valign="top"><div class="box"><br /><a href="'.$dirname.$file.'" rel="lightbox[roadtrip]"><img width="100" height="100" src="'.$dirname.$file.'"></a><br /><input type="radio" name="ch" value="'.$file.'"></div></td></tr>'; } } ?></table>