1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
| <?php
include ("connexion.php");
function mysql_date($champ)
{
$annee=substr($champ,0,4);
$mois=substr($champ,5,2);
$jour=substr($champ,8,2);
return $jour;
}
function premier_jour_du_mois($mois,$annee)
{
$intPremierJour = date("w",mktime(0,0,0,$mois,1,$annee));
if($intPremierJour == 0) $intPremierJour = 7; // si c'est un dimanche
return $intPremierJour-1;
}
function nbjour($m,$a)
{
if(($a%4)==0)
{
$fev=29;
}
else
{
$fev=28;
}
$mois = array(0,31,$fev,31,30,31,30,31,31,30,31,30,31);
for($x=1;$x<13;$x++)
{
if($m == $x)
{
return $mois[$x];
}
}
}
function lister_table()
{
$table="nouv";
$date = array();
$query = "SELECT * FROM table";
$result = mysql_query($query);
while ($val = mysql_fetch_array($result))
{
$date =mysql_date($val["date"]);
echo $date;
}
}
function afficheMois($mois, $annee)
{
$tab = getdate();
$jourc = $tab["mday"];
$anneec = $tab["year"];
$moisc = $tab["mon"];
$labelMois = array(" ","Janvier", "Février", "Mars", "Avril",
"Mai", "Juin", "Juillet", "Août", "Septembre",
"Octobre", "Novembre", "Décembre");
$labelJour = array("Lu.","Ma.","Me.","Je.","Ve.","Sa.","Di.");
$nbJours=nbjour($mois,$annee);
$css = "text";
echo "<div id='titre-calendrier'>
<table border=0 align='center'> \n";
$mp=$mois+1;
$mm=$mois-1;
$ap=$annee+1;
$am=$annee-1;
$acp=$annee;
$acm=$annee;
if($mp==13)
{
$mp=1;
$acp=$acp+1;
if($acp==2038)
{
$acp=1980;
}
}
if($mm==0)
{
$mm=12;
$acm=$acm-1;
if($acm<1980)
{
$acm=2037;
}
}
if($ap>2037){$ap=1980;}
if($am<1980){$am=2037;}
echo "
<tr>".
//modifier les liens ci-dessous avec votre chemin
"<td colspan=\"4\" class=\"$css\"><a href=\" http://essai.net/nouv.php?mois=$mm&annee=$acm\"><img src=\"arrow_left.gif\" border=\"0\">".
"</a> $labelMois[$mois] <a href=\" http://www.essai.net/nouv.php?mois=$mp&annee=$acp\"><img src=\"arrow_right.gif\" border=\"0\"></a></td>";
echo "<td colspan=\"3\" align=\"right\" class=\"$css\"><a href=\" http://www.essai.net/nouv.php?mois=$mois&annee=$am\"><img src=\"arrow_left.gif\" border=\"0\"> ".
"</a>$annee<a href=\" http://www.essais.net/nouv.php?mois=$mois&annee=$ap\ "> <img src=\"arrow_right.gif\" border=\"0\"></a> </td></tr>";
echo "<tr>";
for ($i = 0; $i < 7; $i++) {
echo "<td class=\"$css\">$labelJour[$i]</td>";
}
echo "</tr>\n";
echo "<tr>";
for ($i = 0; $i < premier_jour_du_mois($mois,$annee); $i++)
{
echo "<td></td>";
}
/********************************/
for ($i = 1; $i <= $nbJours; $i++)
{
if (($i-1 + premier_jour_du_mois($mois,$annee)) % 7 == 0)
{
echo "</tr>\n<tr>";// Retour à la ligne chaque Lundi
}
if(($i-1==$jourc-1)&&($annee==$anneec)&&($mois==$moisc))
{
$cssClass = "datejour";
$htmltext = "<td align=\"right\" class=\"$cssClass\">$i</td>";
}
else
{
$cssClass = "date";
$htmltext = "<td align=\"right\" class=\"$cssClass\">$i</td>";
}
/*****************/
$debut_mois = date("Y-m-d", mktime(0,0,0,$mois,1,$annee));
$fin_mois = date("Y-m-d", mktime(0,0,0,$mois,$nbJours,$annee));
$query = "SELECT * FROM nouv where date >='$debut_mois' and date <='$fin_mois' ORDER BY date";
$result = mysql_query($query);
while ($val = mysql_fetch_array($result))
{
$date = mysql_date($val["date"]);
$id = $val["id"];
if($i==$date)
{
$cssClass = "date";
$htmltext = "<td align=\"right\" class=\"$cssClass\"><a href=nouv.php?ref=$id\" class=\"lien\" title=\"date événement\">$i</a></td>";
}
}
echo $htmltext;
}
/******************************/
echo "</tr>";
echo "</table></div>";
}
?> |
Partager