0

guys i'm having a really big problem right now..im trying to make a conditional statement using php but im having an logical error or syntax error..im trying to compute for the car rate but im not getting a correct output

e.g

i have a list of car which are "Small Car" "Innova" "Van" and there prices will depend on the location if the location is let say "Manila" or "Cam Sur" or "Boracay" then
Small Car price is 550.00
Innova price is 700.00
Van price is 1000.00

here is the code

<?php
 $vehicle;
      $rhr;
    $phr;
    $total;
    $totalhr;
    $rday;
    $pday;
    $totald;
    $totalday;
    $rmonth;
    $pmonth;
    $totalm;
    $totalmonth;


if($origin=="NAIA 1" && $vehicle=="Small Car" && $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" )
{
    $perday=3000;
    $permonth=9000;
    $perhour=125;
    $car=1740;

if($rhr>$phr)
        {
        $total=($rhr)- ($phr);
        $totalhr=$perhour * $total;

        }
    else if($rhr==$phr)
        {    
        $totalhr;
        }
    if($rday>$pday)
        {
        $totald=($rday)-($pday);
        $totalday=$perday * $totald;
        }
    else if($rday==$pday)
        {
        $totalday;
        }

    if($rmonth>$pmonth)
        {
        $totalm=$rmonth-$pmonth;
        $totalmonth=$totalm * $permonth;

        }
    else if($rmonth==$pmonth)
        {
        $totalmonth;
        }
        $rate=$car+$totalhr+$totalday;     
}
if($origin=="NAIA 1" && $vehicle=="Innova" && $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" )
{
    $perday=3000;
    $permonth=9000;
    $perhour=125;
    $car=1740;

if($rhr>$phr)
        {
        $total=($rhr)- ($phr);
        $totalhr=$perhour * $total;

        }
    else if($rhr==$phr)
        {    
        $totalhr;
        }
    if($rday>$pday)
        {
        $totald=($rday)-($pday);
        $totalday=$perday * $totald;
        }
    else if($rday==$pday)
        {
        $totalday;
        }

    if($rmonth>$pmonth)
        {
        $totalm=$rmonth-$pmonth;
        $totalmonth=$totalm * $permonth;

        }
    else if($rmonth==$pmonth)
        {
        $totalmonth;
        }
        $rate=$car+$totalhr+$totalday;     
}
if($origin=="NAIA 1" && $vehicle=="Vans" && $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" )
{
    $perday=3000;
    $permonth=9000;
    $perhour=125;
    $car=1740;

if($rhr>$phr)
        {
        $total=($rhr)- ($phr);
        $totalhr=$perhour * $total;

        }
    else if($rhr==$phr)
        {    
        $totalhr;
        }
    if($rday>$pday)
        {
        $totald=($rday)-($pday);
        $totalday=$perday * $totald;
        }
    else if($rday==$pday)
        {
        $totalday;
        }

    if($rmonth>$pmonth)
        {
        $totalm=$rmonth-$pmonth;
        $totalmonth=$totalm * $permonth;

        }
    else if($rmonth==$pmonth)
        {
        $totalmonth;
        }
        $rate=$car+$totalhr+$totalday;     
}                           

?>        

in that code the "or" "||" condtion is not working please need help..

2
Contributors
2
Replies
5
Views
5 Years
Discussion Span
Last Post by ehpratah
1

ok i got it
instead of this
if($origin=="NAIA 1" && $vehicle=="Vans" && $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" )

i put
if(($origin=="NAIA 1" && $vehicle=="Van") &&( $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" ))

and its working now..

Votes + Comments
Thanks for sharing
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.