I know that this is not the way to do it but I'm having some trouble trying to set a variable using conditional statements.
For some context, $foo, $foo_1 and $foo_2 are checking to see if a form field is set, if it is, to set $bar equal to the calculation that accompanies each condition.
if(isset($foo)) {
$bar = ($baz * 52) * ($qux);
}
if(isset($foo_1)) {
$bar = ($baz_1 * 12) * ($qux);
}
if(isset($foo_2)) {
$bar = ($baz_2 * $qux);
}
This is because the existing code uses $bar in a calculation
$a = ($b / $bar)
and $a is passed on further down in a variety of cases.
As it is, only the first $foo condition is passing $bar properly, all other conditions $bar outputs as NULL.
EDIT: To clarify the code above (which was incorrect) and update my example below:
$foo = isset($form['first'] ? $form['first'] : '';
$foo_1 = isset($form['second'] ? $form['second'] : '';
$foo_2 = isset($form['third'] ? $form['third'] : '';
if(isset($foo)) {
$bar = ($foo * 52) * $qux;
}
if(isset($foo_1)) {
$bar = ($foo_1 * 12) * $qux;
}
if(isset($foo_2)) {
$bar = $foo_2 * $qux;
}
Revent, Oswald and RoyalBG's suggestions have pointed out that my code isn't setting variables properly, which is the case. $baz, $baz_1, $baz_2 were deprecated and non-existent and replaced with $foo, $foo_1, $foo_2 to accompany their conditionals for the desired inputs. Once I clean this up I will use a switch statement instead of what I've written above. All of the comments below have been very helpful Thanks for the help.
ifare not mutual excluding.