par
Peet » 27 avr. 2005, 08:37
Bonjour, je commence a programmer en ohp et je dois mettre en place un calendrier. Le pb est que je n'arrive pas a naviguer entre les mois de l'annee avec les fleches ! Dans l'url, on peut vois le passage de parametres.
Par exemple, on est en Avril et quand je clique sur la fleche gauche pour avoir le mois précedent (Mars) rien ne se passe et dans l'url on a bien : ?dt=2005+03+27.
Le pb vient peut etre des href ?!
Merci e jeter un coup d'oeil et de m'aider à m'en sortir
<?
$tabmonth = Array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin","Juillet", "Août", "Septembre", "Octobre", "Novembre","Décembre");
$tabday = Array("Lun", "Mar", "Mer", "Jeu", "Ven", "Sam","Dim");
// selectionne la date d aujourd hui
if (!$dt){
$year = date("Y");
$now = date("Y/m/d");
$month = date("n");
$day = date("d");
}else{
$data=explode(" ",$dt);
$year=$data[0];
$month=$data[1];
$day=$data[2];
$now=date("Y/m/d", mktime(0,0,0,$month,$day,$year));
}
$moyear=$tabmonth[$month-1]." ".$year;
?>
<table WIDTH="550" height="220" BORDER="0" CELLSPACING="0" CELLPADDING="2">
<tr>
<td CLASS='titremois' colspan="8" ALIGN="center">
<?
$lien1=date("Y+m+d", mktime(0,0,0,$month-1,$day,$year));
echo "<A CLASS='titremois' href=\"?dt=$lien1\"><<</a>";
echo "<A CLASS='titremois'> $moyear </a>";
$lien2=date("Y+m+d", mktime(0,0,0,$month+1,$day,$year));
echo "<A CLASS='titremois' href=\"?dt=$lien2\">>></a>";
?>
</td>
</tr>
<tr>
<?
echo"<td WIDTH=30 class='titreweek' ALIGN='center'>NumSem</td>\n";
for ($i=0;$i<7;$i++) {
echo"<td WIDTH=20 class='titrejours' ALIGN='center'>$tabday[$i]</td>\n";
}
?>
</tr>
<?
$num_day=date("w", mktime(0,0,0,$month,01,$year));
if($num_day==0){$num_day=7;}
$max_day=date("t", mktime(0,0,0,$month,01,$year));
$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,$month,$cpt_day$num_day+3,$year));
$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,$month,$cpt_day-$num_day,$year));
$val=date("d", mktime(0,0,0,$month,$cpt_day-$num_day,$year));
$class="titrenum";
if ($now==date("Y/m/d",mktime(0,0,0,$month,$cpt_day-$num_day,$year))){ $class="titrenow";}
if ((($cpt_day-$num_day)<1) or (($cpt_day-$num_day)>$max_day)){
$class="titrenum2";
}
$cpt_day++;
echo "<td WIDTH=20 class='$class'ALIGN='center'>".$val."
</td>\n";
}
echo "</tr>";
}
?>
Bonjour, je commence a programmer en ohp et je dois mettre en place un calendrier. Le pb est que je n'arrive pas a naviguer entre les mois de l'annee avec les fleches ! Dans l'url, on peut vois le passage de parametres.
Par exemple, on est en Avril et quand je clique sur la fleche gauche pour avoir le mois précedent (Mars) rien ne se passe et dans l'url on a bien : ?dt=2005+03+27.
Le pb vient peut etre des href ?!
Merci e jeter un coup d'oeil et de m'aider à m'en sortir
<?
$tabmonth = Array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin","Juillet", "Août", "Septembre", "Octobre", "Novembre","Décembre");
$tabday = Array("Lun", "Mar", "Mer", "Jeu", "Ven", "Sam","Dim");
// selectionne la date d aujourd hui
if (!$dt){
$year = date("Y");
$now = date("Y/m/d");
$month = date("n");
$day = date("d");
}else{
$data=explode(" ",$dt);
$year=$data[0];
$month=$data[1];
$day=$data[2];
$now=date("Y/m/d", mktime(0,0,0,$month,$day,$year));
}
$moyear=$tabmonth[$month-1]." ".$year;
?>
<table WIDTH="550" height="220" BORDER="0" CELLSPACING="0" CELLPADDING="2">
<tr>
<td CLASS='titremois' colspan="8" ALIGN="center">
<?
$lien1=date("Y+m+d", mktime(0,0,0,$month-1,$day,$year));
echo "<A CLASS='titremois' href=\"?dt=$lien1\"><<</a>";
echo "<A CLASS='titremois'> $moyear </a>";
$lien2=date("Y+m+d", mktime(0,0,0,$month+1,$day,$year));
echo "<A CLASS='titremois' href=\"?dt=$lien2\">>></a>";
?>
</td>
</tr>
<tr>
<?
echo"<td WIDTH=30 class='titreweek' ALIGN='center'>NumSem</td>\n";
for ($i=0;$i<7;$i++) {
echo"<td WIDTH=20 class='titrejours' ALIGN='center'>$tabday[$i]</td>\n";
}
?>
</tr>
<?
$num_day=date("w", mktime(0,0,0,$month,01,$year));
if($num_day==0){$num_day=7;}
$max_day=date("t", mktime(0,0,0,$month,01,$year));
$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,$month,$cpt_day$num_day+3,$year));
$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,$month,$cpt_day-$num_day,$year));
$val=date("d", mktime(0,0,0,$month,$cpt_day-$num_day,$year));
$class="titrenum";
if ($now==date("Y/m/d",mktime(0,0,0,$month,$cpt_day-$num_day,$year))){ $class="titrenow";}
if ((($cpt_day-$num_day)<1) or (($cpt_day-$num_day)>$max_day)){
$class="titrenum2";
}
$cpt_day++;
echo "<td WIDTH=20 class='$class'ALIGN='center'>".$val."
</td>\n";
}
echo "</tr>";
}
?>