Danny1125 Posted August 10, 2016 Share Posted August 10, 2016 if(measure=="feat") { result=(wi*he); if(((wi*he))>0) { result=result; } // alert(result); } if(result=="0") { result ="1"; } This is my code. i want the result as : if the result is between 1-50, it should display 1, similarly 51-100 : 2, 101- 150 : 3, 151-200 : 4.... what code should i write in the result part? anyone help me out. its urgent. Quote Link to comment https://forums.phpfreaks.com/topic/301816-if-statement-doubt/ Share on other sites More sharing options...
Jacques1 Posted August 10, 2016 Share Posted August 10, 2016 (edited) Your code doesn't make any sense, and this is clearly JavaScript, not PHP. The display value can be obtained through simple division and the ceiling function: <script> var resultTests = [1, 14, 50, 51, 60, 100, 101, 105, 150, 151, 153, 200]; for (result of resultTests) { var display = Math.ceil(result / 50); console.log(result + " -> " + display); } </script> Edited August 10, 2016 by Jacques1 Quote Link to comment https://forums.phpfreaks.com/topic/301816-if-statement-doubt/#findComment-1535896 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.