alin19 Posted January 8, 2008 Share Posted January 8, 2008 my client must insert a number and a method method A or B(15 and 25) if he chose number x and method A he will get this: x+15/100*x x x-15/100*x i have made this <?php if($_SERVER['REQUEST_METHOD'] == 'POST') { $a = $_POST['unu']; $b = $_POST['doi']; $x= number_format($a, 4, '.', ''); if (isset ($b)){ if ($b=='A) $procent=15; if ($b=='a') $procent=15; } if (isset ($b)) { if ($b=='B') $procent=25; if ($b=='b') $procent=25; } if (isset ($procent)) { $xmax = number_format(($a+($a*$procent/100)), 4, '.', ''); $xmin = number_format(($a-($a*$procent/100)), 4, '.', ''); } } } ?> .... but i have some steps, if ( 0<x<1000) x, min and max is the form abcd a,b,c,d are numbers if ( 1000 <=x<10000) x, min and max is the form abc0 if ( 10000 <=x<100000) x, min and max is the form ab00 the big problem is when x is 900 the i get 1.035 max over 1000 0.9000 x and min under 1000 0.765 i can do this by inserting a lot of if's but it will be had to debug after it, i don't know if i explaind very well, can you help me? Link to comment https://forums.phpfreaks.com/topic/85004-numbers-problem/ Share on other sites More sharing options...
Ken2k7 Posted January 8, 2008 Share Posted January 8, 2008 This is confusing to read. I haven't analyzed what you're trying to do and I don't get it either, but: if (isset ($b)){ if ($b=='A) $procent=15; if ($b=='a') $procent=15; } if (isset ($b)) { if ($b=='B') $procent=25; if ($b=='b') $procent=25; } I don't see the point with the IF statements everywhere. $procent doesn't change if the letter is capital or not. if (isset ($b)){ if ($b=='A' || $b=='a') $procent=15; if ($b=='B' || $b=='b') $procent=25; } Link to comment https://forums.phpfreaks.com/topic/85004-numbers-problem/#findComment-433534 Share on other sites More sharing options...
alin19 Posted January 8, 2008 Author Share Posted January 8, 2008 if i had set A and the web client posted a only the x number would be "echo" on the page, min and max don't appear there Link to comment https://forums.phpfreaks.com/topic/85004-numbers-problem/#findComment-433549 Share on other sites More sharing options...
Ken2k7 Posted January 8, 2008 Share Posted January 8, 2008 Okay so say I typed the numbers 5 and 80 and method A. Can you lay out what this would do? Link to comment https://forums.phpfreaks.com/topic/85004-numbers-problem/#findComment-433558 Share on other sites More sharing options...
alin19 Posted January 8, 2008 Author Share Posted January 8, 2008 well just add 15% of that number and decrease 15% of that number the same with 25% it just eases this to some people, but i need to complete it to be more helpful Link to comment https://forums.phpfreaks.com/topic/85004-numbers-problem/#findComment-433565 Share on other sites More sharing options...
Ken2k7 Posted January 8, 2008 Share Posted January 8, 2008 <?php if ($_POST['submit'] && !empty($_POST['unu']) && !empty($_POST['doi'])){ $a = $_POST['unu']; $b = $_POST['doi']; if (preg_match("/a/i",$b) $procent = .25; if (preg_match("/b/i",$b) $procent = .15; echo $procent * $a . "<br />" . $a . "<br />" . ($procent+1) * a; ?> Link to comment https://forums.phpfreaks.com/topic/85004-numbers-problem/#findComment-433573 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.