Edit: Solved! Thank you all for pointing out the missing concatenation operator and missing punctuation.
I've just been introduced to PHP and am trying to work on a basic exercise where I use a for-loop in combination with several if/elseif statements.
My variables A and B are related mathematically, and I need the output to state the value of B along with a simple word ('Good', 'bad', 'okay'- depending on the resultant value of B). I'd also like each result of the loop to be printed on a new line.
My attempt can be seen below:
<?php
for ($A = 0; $A <= 100; $A++){
$B = (2/3) * ($A - 25);
if ($B < 0 {
echo $B ", Bad <br>";}
elseif ($B > 45 {
echo $B ", Good <br>";}
else {
echo $B ", Okay <br>";}
}
endfor;
?>
This is only my second day of working with PHP (and the first time I've written a loop statement of any kind in about seven years) so I apologize if my errors are glaring.
Do I need to move my definition of $B? Do I need to split this statement up somehow? Is it my echo statements that are the issue? Any hints or explanations are greatly appreciated. Thanks!
"; // Error – AkshayP Mar 15 '16 at 10:49