473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

problem with if statement help

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
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  $vehicle;
  3.       $rhr;
  4.     $phr;
  5.     $total;
  6.     $totalhr;
  7.     $rday;
  8.     $pday;
  9.     $totald;
  10.     $totalday;
  11.     $rmonth;
  12.     $pmonth;
  13.     $totalm;
  14.     $totalmonth;
  15.  
  16.  
  17. if($origin=="NAIA 1" && $vehicle=="Small Car" && $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" )
  18. {
  19.     $perday=3000;
  20.     $permonth=9000;
  21.     $perhour=125;
  22.     $car=1740;
  23.  
  24. if($rhr>$phr)
  25.         {
  26.         $total=($rhr)- ($phr);
  27.         $totalhr=$perhour * $total;
  28.  
  29.         }
  30.     else if($rhr==$phr)
  31.         {    
  32.         $totalhr;
  33.         }
  34.     if($rday>$pday)
  35.         {
  36.         $totald=($rday)-($pday);
  37.         $totalday=$perday * $totald;
  38.         }
  39.     else if($rday==$pday)
  40.         {
  41.         $totalday;
  42.         }
  43.  
  44.     if($rmonth>$pmonth)
  45.         {
  46.         $totalm=$rmonth-$pmonth;
  47.         $totalmonth=$totalm * $permonth;
  48.  
  49.         }
  50.     else if($rmonth==$pmonth)
  51.         {
  52.         $totalmonth;
  53.         }
  54.         $rate=$car+$totalhr+$totalday;     
  55. }
  56. if($origin=="NAIA 1" && $vehicle=="Innova" && $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" )
  57. {
  58.     $perday=3000;
  59.     $permonth=9000;
  60.     $perhour=125;
  61.     $car=1740;
  62.  
  63. if($rhr>$phr)
  64.         {
  65.         $total=($rhr)- ($phr);
  66.         $totalhr=$perhour * $total;
  67.  
  68.         }
  69.     else if($rhr==$phr)
  70.         {    
  71.         $totalhr;
  72.         }
  73.     if($rday>$pday)
  74.         {
  75.         $totald=($rday)-($pday);
  76.         $totalday=$perday * $totald;
  77.         }
  78.     else if($rday==$pday)
  79.         {
  80.         $totalday;
  81.         }
  82.  
  83.     if($rmonth>$pmonth)
  84.         {
  85.         $totalm=$rmonth-$pmonth;
  86.         $totalmonth=$totalm * $permonth;
  87.  
  88.         }
  89.     else if($rmonth==$pmonth)
  90.         {
  91.         $totalmonth;
  92.         }
  93.         $rate=$car+$totalhr+$totalday;     
  94. }
  95. if($origin=="NAIA 1" && $vehicle=="Vans" && $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" )
  96. {
  97.     $perday=3000;
  98.     $permonth=9000;
  99.     $perhour=125;
  100.     $car=1740;
  101.  
  102. if($rhr>$phr)
  103.         {
  104.         $total=($rhr)- ($phr);
  105.         $totalhr=$perhour * $total;
  106.  
  107.         }
  108.     else if($rhr==$phr)
  109.         {    
  110.         $totalhr;
  111.         }
  112.     if($rday>$pday)
  113.         {
  114.         $totald=($rday)-($pday);
  115.         $totalday=$perday * $totald;
  116.         }
  117.     else if($rday==$pday)
  118.         {
  119.         $totalday;
  120.         }
  121.  
  122.     if($rmonth>$pmonth)
  123.         {
  124.         $totalm=$rmonth-$pmonth;
  125.         $totalmonth=$totalm * $permonth;
  126.  
  127.         }
  128.     else if($rmonth==$pmonth)
  129.         {
  130.         $totalmonth;
  131.         }
  132.         $rate=$car+$totalhr+$totalday;     
  133. }                            ?>        
  134.  
  135.  

in that code the "or" "||" condtion is not working please need help...
Jun 9 '12 #1
2 1541
Luuk
1,047 Expert 1GB
you should probabley change lines like this:
Expand|Select|Wrap|Line Numbers
  1. if($origin=="NAIA 1" && $vehicle=="Small Car" && $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" ) 
to
Expand|Select|Wrap|Line Numbers
  1. if($origin=="NAIA 1" && $vehicle=="Small Car" && ( $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" ) ) 
Because '&&' has higher precedence than '||'
(see: docs )
Jun 9 '12 #2
yeah thanks for the advice..i figured it out already but again thanks
Jun 11 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Gert v O | last post by:
I've posted the following question once: I have a column in a table The first 1, 2 or 3 alphabetic characters of gives the category of the example: ms123 --> category MS f-2345 -->...
0
by: Prasanth U | last post by:
Hi All, We are facing a problem while integrating a HTML help file (chm version 1.x) to our windows .net application (C#). The help topic for the controls in the application are shown using the...
2
by: Little PussyCat | last post by:
Hello, I hope you can help me. We have a SQL Server 2000 database at work, (which works with a VB6 frontend) which grew to a considerable size, so one of my past colleagues sent me this...
9
by: Peter | last post by:
My problem is the last bit of coding below, the like statement does not work. what I have is a product options field and in it is stored characters i.e. "avcy" etc what the query does is...
2
by: anolith | last post by:
Hello Everyone! I'm wondering if someone could help me out with this problem. We have a database in Access for our library. We also have it linked to a web search. If a book is authored by two...
11
by: Scott C. Reynolds | last post by:
In VB6 you could do a SELECT CASE that would evaluate each case for truth and execute those statements, such as: SELECT CASE True case x > y: dosomestuff() case x = 5: dosomestuff() case y >...
0
by: feeblemind | last post by:
Hi everyone, I am having problem/troubles with creating an sql inline statement for our application. How do I create a statement/query that selects list of servers with defined date ranges, but...
3
adelemb
by: adelemb | last post by:
Hi all, We have an Oracle database and my problem is with SQL, apologies if this is posted in the wrong forum. I have this SQL statement that all works fine: var newConn = new...
0
by: sa6113 | last post by:
I want to connect to a Windows machine in my network , using ssh, I use paramiko but I have problem in authentication, would you please help me? 1- I have installed freeSSHD in server machine? Is...
3
by: erik6408 | last post by:
I am trying to use the IIF statement to look for a null value. That seems to be working fine.. The problem occurs when I use a LIKE Statement inside the IIF statement. Here are some examples:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.