simple arithmetic question
Moderator: General Moderators
simple arithmetic question
Okay, I'm feeling pretty stupid at the moment as I'm sure there is a simple way to do this, but I just can't think of it.
I'm trying to perform an addition inside a select menu with:
echo "<option value='$nextGradClass+5'>7</option>";
where $nextGradClass has a numerical value defined earlier, of say 2006.
However, it's not getting evaluated server side and
<option value='2006+5'>7</option>
is instead being sent to the client.
Please chastise me, but give me a clue too
I'm trying to perform an addition inside a select menu with:
echo "<option value='$nextGradClass+5'>7</option>";
where $nextGradClass has a numerical value defined earlier, of say 2006.
However, it's not getting evaluated server side and
<option value='2006+5'>7</option>
is instead being sent to the client.
Please chastise me, but give me a clue too
there a few ways you can do it, all fairly simple.
Code: Select all
echo '<option value="' . $nextGradClass+5 . '">7</option>';sorry.
this will work, but the other example should too.
this will work, but the other example should too.
Code: Select all
$newGradClass = $nextGradClass + 5;
echo "<option value="$newGradClass">7</option>";Parenthesis, Exponents, Multiplication, Division, Addition, Subtraction. In that order. It was at least that way where I went to school, but i'm not omnipotent so I could be forgetting something.
In math the statements x + 5 and (x + 5) are the same.
But I guess I don't understand something in php.
In math the statements x + 5 and (x + 5) are the same.
But I guess I don't understand something in php.
Last edited by nigma on Wed Aug 04, 2004 8:41 pm, edited 1 time in total.
Haha, this was posted in response to jamie's last post, but didn't post in time.
Yea, could be ?
Anyway, glad you got things worked out, give me a few minutes and I won't be making the same mistake again.
Yea, could be ?
Anyway, glad you got things worked out, give me a few minutes and I won't be making the same mistake again.
Last edited by nigma on Wed Aug 04, 2004 8:46 pm, edited 1 time in total.