<?php
$sent = $_POST["sent"];
// Erstmal legen wir das Array an, welches die verschiedenen Perioden beinhaltet
$phase[Hauptsaison] = "2007-07-01,2007-10-01,25";
$phase[Nebensaison] = "2007-10-02,2007-11-01,20";
$phase[Weihnachtszeit] = "2007-11-02,2007-12-31,50";
foreach($phase as $element => $d) {
$daten = explode(",", $d);
echo "Phase: ".$element."";
echo "von ".date("d.m.Y", strtotime($daten[0]))." - ".date("d.m.Y", strtotime($daten[1]))."<hr noshade size='0' color='#000000'>";
echo $daten[2].',00 € pro Übernachtung <br><br>';
}
if(isset($sent)) {
$von = strtotime($_POST["von"]);
$bis = strtotime($_POST["bis"]);
$preis = 0;
if(!isset($date)) {
$date = $von-86400;
}
while($date < $bis) {
$date = $date+86400;
foreach($phase as $element => $d) {
$daten = explode(",", $d);
$phasevon = strtotime($daten[0]);
$phasebis = strtotime($daten[1]);
if(($date >= $phasevon) && ($date <= $phasebis)) {
$preis += $daten[2];
echo ''.date("d.m.Y", $date). ' - <b>'.$daten[2].',00 €</b><br>';
}
}
}
echo "Der Gesamtpreis liegt bei: ".$preis.",00 €<br><br>";
}
?>
<html>
<head>
<title>Preisrechner</title>
</head>
<form name="f" method="POST" action="<?php echo $PHP_SELF;?>">
Von: <input type="text" name="von">
Bis: <input type="text" name="bis">
<input type="hidden" name="sent" value="1">
<input type="submit" value="Rechnen">
</form>
</html>