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..

Recommended Answers

All 2 Replies

If you mix && and || be sure to use parenthesis, to ensure the correct order of processing.

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..

commented: Thanks for sharing +13
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.