<?php
$ListeVar = array('month','day', 'year');
foreach($ListeVar as $val){
$_POST[$val] = (isset($_POST[$val])) ? $_POST[$val] : "";
}
if ($_POST['month']!="") {
if ($_POST['compute'] == 'sub') {
$_POST['day'] = $_POST['day'] + 63;
} elseif ($_POST['compute'] == 'add') {
$_POST['day'] = $_POST['day'] + 73;
}
$echo = date($_POST['output'], mktime (0,0,0,$_POST['month'],$_POST['day'],$_POST['year'])); //ceci est la date
}
echo "
<form action="" method=post>
<table border=0 cellspacing=1 cellpadding=2 bgcolor=blue width=300>
<tr>
<td bgcolor=blue><font color=white face=arial><B>Date Calculée"; if (!empty($echo)) {echo " - Résultat: $echo";} echo "</B></font></td>
</tr>
<tr>
<td bgcolor=white>
<table border=0 cellpadding=3 cellspacing=0>
<tr>
<td aligin=left><font color=blue face=arial>Choisir date: </font></td><td aligin=left><select name=day>";
getoption(1, 31, date("d"));
echo "</select><select name=month>";
getoption(1, 12, date("m"));
echo "</select><select name=year>";
getoption(1970, 2020, date("Y"));
echo "</select></td>
</tr>
<tr>
<td aligin=left><font color=blue face=arial>Additionner/Soustraire </font></td><td aligin=left><select name=compute><option value=add>maximum<option value=sub>minimum</select>
</td>
</tr>
<tr>
<td aligin=left><font color=blue face=arial>Format de sortie: </font></td><td aligin=left><select name=output><option value="d-m-Y">dd-mm-YYYY<option value="l, d M Y">weekday, dd mm yyyyy</select></td>
</tr>
<tr>
<td aligin=left colspan=2><input type=submit name=submit value=Calculer></td>
</tr>
</table>
</td></tr></table></form>";
function getoption($start, $end, $if) {
for ($i=$start;$i<=$end;$i++) {
echo "<option value=$i"; if ($i == $if) { echo " selected";} echo ">$i";
}
}
?>
Je n'ai pas testé dans un bloc xoops, mais ce code est plus propre... (je ne sais toujours vraiment pas comment le tiens pouvait fonctionner...)