Calculate Prices between low and high seasons
Posted: Tue Jun 13, 2006 2:42 am
Hi everybody,
I am trying to calculate the prices depending on the seasons as there are two seasons, one low and the other high. My problem is that i can't compare the seasons to get the total price and it is not displaying like i want.
check this following script, especially at the bottom which are in bold red font.
if (($compare=$result1) && ($compare=$result3))
{
$total=$day_diff*$price_low;
echo $total;
}
elseif (($compare=$result2) && ($compare=$result4))
{
$total=$day_diff*$price_high;
echo $total;
}
else
{
echo "Price is low + high";
}
Hope that I'll get a reply soon!!!
I am trying to calculate the prices depending on the seasons as there are two seasons, one low and the other high. My problem is that i can't compare the seasons to get the total price and it is not displaying like i want.
check this following script, especially at the bottom which are in bold red font.
Code: Select all
<?php
$a_day=$_POST['arrival_date'];
$a_month=$_POST['arrival_month'];
$a_year=$_POST['arrival_year'];
$result1="Low season";
$result2="High season";
$result3="Low season";
$result4="High season";
$price_low=40;
$price_high=50;
$arrivaldate = mktime(0, 0, 0, $a_month, $a_day, $a_year);
//Low season
$beginL = mktime(0, 0, 0, 05, 01, 2006);
$endL = mktime(0, 0, 0, 10, 14, 2006);
//high season
$beginH = mktime(0, 0, 0, 10, 15, 2006);
$endH = mktime(0, 0, 0, 04, 15, 2007);
if (($arrivaldate >= $beginL) and ($arrivaldate <= $endL)) {
echo "The arrival date is in ".$result1;
}
elseif (($arrivaldate >= $beginH) and ($arrivaldate <= $endH)) {
echo "The arrival date is in ".$result2;
}
else
{
echo "other season";
}
echo "<BR>";
?>
<?php
$d_day=$_POST['departure_date'];
$d_month=$_POST['departure_month'];
$d_year=$_POST['departure_year'];
$compare="";
$depart_date = mktime(0, 0, 0, $d_month, $d_day, $d_year);
//Low season
$beginL = mktime(0, 0, 0, 05, 01, 2006);
$endL = mktime(0, 0, 0, 10, 14, 2006);
//high season
$beginH = mktime(0, 0, 0, 10, 15, 2006);
$endH = mktime(0, 0, 0, 04, 15, 2007);
if (($depart_date >= $beginL) and ($depart_date <= $endL)) {
echo "The departure date is found in ".$result3;
}
elseif (($depart_date >= $beginH) and ($depart_date <= $endH)) {
echo "The departure date is found in ".$result4;;
}
else
{
echo "other season";
}
echo "<BR>";
if ($depart_date<$arrivaldate)
{
echo "Date of departure cannot be less than date of arrival";
echo "<BR>";
}
else
{
$arrivaldate = mktime(0, 0, 0, $a_month, $a_day, $a_year);
$depart_date = mktime(0, 0, 0, $d_month, $d_day, $d_year);
$year_diff = date('y', $depart_date) - date('y',$arrivaldate);
$month_diff = date('m', $depart_date) - date('m',$arrivaldate) + ($year_diff * 12) ;
$day_diff = date('z', $depart_date) - date('z',$arrivaldate) + (((int) date('L',$arrivaldate)) ? ($year_diff * 366) : ($year_diff * 365) );
echo $day_diff. " days";
echo "<BR>";
}{
$total=$day_diff*$price_low;
echo $total;
}
elseif (($compare=$result2) && ($compare=$result4))
{
$total=$day_diff*$price_high;
echo $total;
}
else
{
echo "Price is low + high";
}
Code: Select all
?>