Jump to content

numbers problem


alin19

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.