monkeybidz Posted September 27, 2007 Share Posted September 27, 2007 I have these two: When miles are equal or below 30 i am to get "Same Day", instead i am getting "8-9 Days". It seems to ignore the 0000's after the 3. $english_format_number = number_format($miles); if($miles <=30 && $service_type == 1){ $etd = "Same Day."; } if($miles <=3000 && $service_type == 1){ $etd = "8-9 Days."; } Any help is appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/70968-number-question/ Share on other sites More sharing options...
MadTechie Posted September 27, 2007 Share Posted September 27, 2007 if($miles <=30 && $service_type == 1){ $etd = "Same Day."; } //true so $etd = "Same Day."; if($miles <=3000 && $service_type == 1){ $etd = "8-9 Days."; } //Also true so NOW .. $etd = "8-9 Days."; try this if($miles <=3000 && $service_type == 1){ $etd = "8-9 Days."; } if($miles <=30 && $service_type == 1){ $etd = "Same Day."; } Quote Link to comment https://forums.phpfreaks.com/topic/70968-number-question/#findComment-356793 Share on other sites More sharing options...
MmmVomit Posted September 27, 2007 Share Posted September 27, 2007 . Quote Link to comment https://forums.phpfreaks.com/topic/70968-number-question/#findComment-356801 Share on other sites More sharing options...
emehrkay Posted September 27, 2007 Share Posted September 27, 2007 use if elseif notation if(miles <= 30){ }elseif(miles <= 3000){ }... Quote Link to comment https://forums.phpfreaks.com/topic/70968-number-question/#findComment-356816 Share on other sites More sharing options...
monkeybidz Posted September 27, 2007 Author Share Posted September 27, 2007 The only problem with using elseif is that i have several more numbers in between. 30 and 3000 was just an example. Is there a way i can just use something like: if($miles == 1-30 31-90 and so on What would i use as "to, through or -"? Quote Link to comment https://forums.phpfreaks.com/topic/70968-number-question/#findComment-356859 Share on other sites More sharing options...
MadTechie Posted September 28, 2007 Share Posted September 28, 2007 i think you mean if($miles >= 1 && $miles <=30) { //....true 1 to 30 }elseif($miles >= 31 && $miles <=90){ //....true 31 to 90 } Quote Link to comment https://forums.phpfreaks.com/topic/70968-number-question/#findComment-356861 Share on other sites More sharing options...
Barand Posted September 28, 2007 Share Posted September 28, 2007 or test against the largest first <?php if($miles <=3000 && $service_type == 1){ $etd = "8-9 Days."; } if($miles <=30 && $service_type == 1){ $etd = "Same Day."; } Quote Link to comment https://forums.phpfreaks.com/topic/70968-number-question/#findComment-356868 Share on other sites More sharing options...
MadTechie Posted September 28, 2007 Share Posted September 28, 2007 i covered that Barand 2nd post Quote Link to comment https://forums.phpfreaks.com/topic/70968-number-question/#findComment-356872 Share on other sites More sharing options...
Barand Posted September 28, 2007 Share Posted September 28, 2007 So you did, sorry, I only looked at the top bit. Guess it was the lack of quote/code tags USE[ code ][ /code ]PLEASE Quote Link to comment https://forums.phpfreaks.com/topic/70968-number-question/#findComment-356878 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.