calendrier et lien
Posté : 03 juin 2008, 22:35
Salut,
J'ai réaliser un petit calendrier pour mon site, j'ai cependant un petit problème. Je ne vois pas comment faire pour avancer d'un mois ou reculer d'un mois en cliquer sur le lien.
Si quelqu'un aurait une idée, c'est très volontier.
J'ai réaliser un petit calendrier pour mon site, j'ai cependant un petit problème. Je ne vois pas comment faire pour avancer d'un mois ou reculer d'un mois en cliquer sur le lien.
Si quelqu'un aurait une idée, c'est très volontier.
Code : Tout sélectionner
<style type="text/css">
<!--
.titreMois { font-family: Helvetica, Arial; font-size: 13px; font-weight: bold; color: black ; background: #FF7F50 }
.titremois:link { font-family: Helvetica, Arial; font-size: 13px; font-weight: bold; color: white; background: #FF7F50; text-decoration: none }
.titremois:visited { font-family: Helvetica, Arial; font-size: 13px; font-weight: bold; color: white; background: #FF7F50; text-decoration: none }
.titremois:hover { font-family: Helvetica, Arial; font-size: 13px; font-weight: bold; color: #FF0000; background: #FF7F50; text-decoration: underline }
.titrejours { font-family: Helvetica, Arial; font-size: 9px; color: white; background: #FF7F50 }
.titrenum { font-family: Helvetica, Arial; font-size: 11px; color: white; background: #FF7F50 }
.titrenum2 { font-family: Helvetica, Arial; font-size: 11px; color: black; background: #FF7F50}
.titreweek { font-family: Helvetica, Arial; font-size: 9px; color: black; background: #FF7F50}
.titreweek2 { font-family: Helvetica, Arial; font-size: 11px; color: v; background: #FF7F50}
.titrewend { font-family: Helvetica, Arial; font-size: 11px; color: white; background: #B22222 }
.titrewend2 { font-family: Helvetica, Arial; font-size: 11px; color: black; background: #B22222 }
.titrenow { font-family: Helvetica, Arial; font-size: 11px; color: white; background: #8B0000 }
-->
</style>
<?
//Création des variables tableaux
$tableauMois = Array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin","Juillet", "Août", "Septembre", "Octobre", "Novembre","Décembre");
$tableauJour = Array("Lun", "Mar", "Mer", "Jeu", "Ven", "Sam","Dim");
//Selection de la date du jour
$annee = date("Y");
$mois = date("m");
$jour = date("d");
$DateDuJour=date("Y/m/d");
//Création de la variable pour l'affichage du titre
$MoisAnnee=$tableauMois[$mois-1]." ".$annee;
?>
<table width="300" border="0" cellspacing="0" cellpadding="2">
<tr>
<td class='titreMois' colspan="8" align="center">
<?
$lien=date("Y+m+d", mktime(0,0,0,$mois-1,$jour,$annee));
echo "<a class='titreMois' href=\"?dt=$lien\"><<</a>";
echo "<a class='titreMois'> $MoisAnnee </a>";
$lien=date("Y+m+d", mktime(0,0,0,$mois+1,$jour,$annee));
echo "<a class='titreMois' href=\"?dt=$lien\">>></a>";
?>
</td>
</tr>
<tr>
<?
echo"<td WIDTH=20 class='titreweek' ALIGN='center'>Sem</td>\n";
for ($i=0;$i<7;$i++) {
echo"<td WIDTH=20 class='titrejours' ALIGN='center'>$tableauJour[$i]</td>\n";
}
?>
</tr>
<?
$num_day=date("w", mktime(0,0,0,$mois,01,$annee));
if($num_day==0){$num_day=7;}
$max_day=date("t", mktime(0,0,0,$mois,01,$annee));
$cpt_day=2;
while ($cpt_day<=$max_day+$num_day) {
echo "<tr>";
// calcul le numero de semaine
$nb_day=date("z", mktime(0,0,0,$mois,$cpt_day-$num_day+3,$annee));
$val=intval($nb_day/7)+1;
echo "<td WIDTH=20 class='titreweek2' ALIGN='center'>".(($val < 10) ? "0".$val : $val)."</td>\n";
// affiche les jours du mois
for ($i=0;$i<7;$i++) {
$theday=date("D", mktime(0,0,0,$mois,$cpt_day-$num_day,$annee));
$val=date("d", mktime(0,0,0,$mois,$cpt_day-$num_day,$annee));
$class="titrenum";
if (($theday=="Sun") or ($theday=="Sat")){ $class="titrewend";}
if ($DateDuJour==date("Y/m/d",mktime(0,0,0,$mois,$cpt_day-$num_day,$annee))){ $class="titrenow";}
if ((($cpt_day-$num_day)<1) or (($cpt_day-$num_day)>$max_day)){
$class="titrenum2";
if (($theday=="Sun") or ($theday=="Sat")){ $class="titrewend2";}
}
$cpt_day++;
echo "<td WIDTH=20 class='$class'ALIGN='center'>".$val."</td>\n";
}
echo "</tr>";
}
?>
</table>