[Solved] php calculator switching multiplier based on input


It is simple, but you must provide the user way enter that value.

For example by the GET parameter number
$userInput = $_GET['number'];

Then you only need to create basic if statement. You can read about it at http://php.net/manual/en/control-structures.if.php

$somma = $bxs+$bs+$bm+$bl+$bxl+$b2xl+$nxs+$ns+$nm+$nl+$nxl+$n2xl;
if($userInput <= 30){
    $somma *=$m1;
}else if($userInput >30) {
    $somma *=$m2;
} else if($userInput > 8779){ // your number : )
    $somma *=$m3;
}

1

solved php calculator switching multiplier based on input