Sos debutante , affichage d'un tableau
Fermé
bilane
Messages postés
13
Date d'inscription
samedi 2 septembre 2006
Statut
Membre
Dernière intervention
21 mars 2007
-
18 sept. 2006 à 11:41
Corni - 18 sept. 2006 à 15:42
Corni - 18 sept. 2006 à 15:42
A voir également:
- Sos debutante , affichage d'un tableau
- Tableau croisé dynamique - Guide
- Tableau ascii - Guide
- Tableau word - Guide
- Le nom du champ de tableau croisé dynamique n'est pas valide ✓ - Forum Excel
- Adèle consulte son compte sur le site de sa banque et obtient l'affichage ci-dessous. complétez le texte. - Forum Facebook
2 réponses
elghafoud
Messages postés
121
Date d'inscription
jeudi 20 février 2003
Statut
Membre
Dernière intervention
29 avril 2013
18
18 sept. 2006 à 15:39
18 sept. 2006 à 15:39
j'ai completement changé ton script ::: voici ma version,,, a toi de voir combien de colonnes tu veux et quelle date commance le compteur! !!
<?php
echo '<center><h4>Recherche par Année </br></br></br></h4></center>';
$year = date("Y");
$year_end = 1977;
$nb_col = 5;
echo '<table width="300px" border="1">';
while ($year > $year_end) {
if ($i==$nb_col) {
echo "</tr>";
$i=0;
}
if ($i==0) {
echo "<tr>";
}
echo "<td>$year</td>";
$i++;
$year--;
}
if ($i>0 && $i<$nb_col) {
while ($i<$nb_col) {
echo "<td> </td>";
$i++;
}
echo "</tr>";
}
echo '</table>';
?>
<?php
echo '<center><h4>Recherche par Année </br></br></br></h4></center>';
$year = date("Y");
$year_end = 1977;
$nb_col = 5;
echo '<table width="300px" border="1">';
while ($year > $year_end) {
if ($i==$nb_col) {
echo "</tr>";
$i=0;
}
if ($i==0) {
echo "<tr>";
}
echo "<td>$year</td>";
$i++;
$year--;
}
if ($i>0 && $i<$nb_col) {
while ($i<$nb_col) {
echo "<td> </td>";
$i++;
}
echo "</tr>";
}
echo '</table>';
?>
Voici une autre possiblité assez proche:
<?php $nbCol = 5; $startYear = 1997; $endYear = date('Y'); print("<table>\n"); $year = $startYear; while ($year <= $endYear) { $colCount = 0; print("<tr>"); while ($colCount <= $nbCol) { if ($year > $endYear) { print("<td> </td>\n"); } else { print("<td>".$year."</td>\n"); } $colCount++; $year++; } print("</tr>\n"); } print("</table>");