par
Topaze » 24 juil. 2005, 21:33
Salut à tous,
J'aimerais créer un calendrier qui va afficher chaque mois sur ma page mais cela me donne un peu de souci. voici le script :
<?
function makeCalendar($month, $year);
$year = (int)($year+($month-1)/12);
$month = (($month-1)%12+1);
$html_code = "<table>";
$html_code = "<tr><th>";
$html_code = getMonth($month,1) . " " . $year;
$html_code = "</th></tr>";
$html_code = "</table>";
echo $html_code;
function getMonth($month, $majuscule=false)
{
$mois = array('janvier','février','mars','avril','mai',
'juin','juillet','août','septembre','octobre','novembre','décembre' );
if ($majuscule) { return ucfirst($mois[($month-1)%12]); }
else { return $mois[($month-1)%12]; }
}
function getDaysNumber($month, $year)
{
return date("t", mktime(0,0,0,$month,1,$year));
}
function getDayOfWeekNumber($day, $month, $year)
{
$n = date("w", mktime(0,0,0,$month,1,$year));
if ($n==0) { $n = 7; }
return $n;
}
$html_code = "<table>";
$html_code = "<tr><th colspan=7>";
$html_code = getMonth($month,1) . " " . $year;
$html_code = "</th></tr>";
$x=0;
$j=1;
$daysNumber = getDaysNumber($month,$year);
$firstDayNumber = getDayOfWeekNumber(1,$month,$year);
while ($j<=$daysNumber)
{
if ($x%7==0) { echo "<tr>"; }
if ($j==1)
{for ($i=1;$i<$firstDayNumber;$i++)
{
$html_code = "<td> </td>";
$x++;
}
}
$html_code = "<td">;
if (date("j.m.y")==date("j.m.y", mktime(0,0,0,$month,$j,$year)))
{ $html_code = " style=background:red"; }
$html_code = ">$j</td>";
$x++;
if ($x%7==0) { $html_code = "</tr>"; }
$j++;
}
$html_code = "</table>";
?>
Quand je l'exécute j'ai ce message
Parse error: parse error, expecting `'{'' in c:\easyphp1-8\www\site\test1.php on line 3
Lorsque j'ajoute { j'ai toujours le même message. Est ce que quelqu'un pourra y jeter un coup de pour me dire où se trouve l'erreur.
Merci
Salut à tous,
J'aimerais créer un calendrier qui va afficher chaque mois sur ma page mais cela me donne un peu de souci. voici le script :
[php]<?
function makeCalendar($month, $year);
$year = (int)($year+($month-1)/12);
$month = (($month-1)%12+1);
$html_code = "<table>";
$html_code = "<tr><th>";
$html_code = getMonth($month,1) . " " . $year;
$html_code = "</th></tr>";
$html_code = "</table>";
echo $html_code;
function getMonth($month, $majuscule=false)
{
$mois = array('janvier','février','mars','avril','mai',
'juin','juillet','août','septembre','octobre','novembre','décembre' );
if ($majuscule) { return ucfirst($mois[($month-1)%12]); }
else { return $mois[($month-1)%12]; }
}
function getDaysNumber($month, $year)
{
return date("t", mktime(0,0,0,$month,1,$year));
}
function getDayOfWeekNumber($day, $month, $year)
{
$n = date("w", mktime(0,0,0,$month,1,$year));
if ($n==0) { $n = 7; }
return $n;
}
$html_code = "<table>";
$html_code = "<tr><th colspan=7>";
$html_code = getMonth($month,1) . " " . $year;
$html_code = "</th></tr>";
$x=0;
$j=1;
$daysNumber = getDaysNumber($month,$year);
$firstDayNumber = getDayOfWeekNumber(1,$month,$year);
while ($j<=$daysNumber)
{
if ($x%7==0) { echo "<tr>"; }
if ($j==1)
{for ($i=1;$i<$firstDayNumber;$i++)
{
$html_code = "<td> </td>";
$x++;
}
}
$html_code = "<td">;
if (date("j.m.y")==date("j.m.y", mktime(0,0,0,$month,$j,$year)))
{ $html_code = " style=background:red"; }
$html_code = ">$j</td>";
$x++;
if ($x%7==0) { $html_code = "</tr>"; }
$j++;
}
$html_code = "</table>";
?>[/php]
Quand je l'exécute j'ai ce message
Parse error: parse error, expecting `'{'' in c:\easyphp1-8\www\site\test1.php on line 3
Lorsque j'ajoute { j'ai toujours le même message. Est ce que quelqu'un pourra y jeter un coup de pour me dire où se trouve l'erreur.
Merci