Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Calculate Prices between low and high seasons
Old 06-13-2006, 03:40 AM Calculate Prices between low and high seasons
Novice Talker

Posts: 6
Trades: 0
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.

<?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>";
}
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!!!
z_cool is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-13-2006, 05:54 AM Re: Calculate Prices between low and high seasons
Novice Talker

Posts: 6
Trades: 0
Its seems that there's no one that can help me!!
z_cool is offline
Reply With Quote
View Public Profile
 
Old 06-13-2006, 06:19 AM Re: Calculate Prices between low and high seasons
Ultra Talker

Posts: 256
Location: Auckland, New Zealand
Trades: 0
Give it some time, not everyone here is a PHP expert, I just found this topic now while doing my daily browsing so I'll try to correct your problem.

OK, so I only looked at your bold red bit first, and can see you're not doing comparisons but actually assignments.

Comparison operator for equal to (==) Asignment operator (=) this can definitely fail your script. Fix that and then let me know how it goes, also can you post your code inside the BBCode's PHP tag so it makes it easier to read.

If that's not what you're wanting then try to explain your code in psuedo talk, I could not see where you assigned compare so maybe you wanted to do the assignment there, but using the same variable means you'll overwrite it when the next boolean statement is evaluated, so a lot of confusion there.

Cheers,

MC
__________________
#------------------------------signature---------------------------------------------------------------------------------#
Quote:
I am well recognised for what I don't do than what I do. Chores are just one of those things.

Last edited by mastercomputers; 06-13-2006 at 06:25 AM..
mastercomputers is offline
Reply With Quote
View Public Profile Visit mastercomputers's homepage!
 
Reply     « Reply to Calculate Prices between low and high seasons
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23889 seconds with 12 queries