PHP Addition

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
4Boredom
Forum Contributor
Posts: 176
Joined: Tue Nov 08, 2005 4:29 pm

PHP Addition

Post by 4Boredom »

I am trying to make a variable addition code like this

Code: Select all

$addedvalue = 5;

$mysqlvalue + $addedvalue = $totalvalue;

print($totalvalue);
totalvalue has been displaying as 0. It should not display as 0.

anyone know how to fix this
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Code: Select all

$totalvalue = $mysqlvalue + $addedvalue
Assignment always works in the order that whatever's on the left of the assignment operator (=) is given the value of whatever's on the right of it.
4Boredom
Forum Contributor
Posts: 176
Joined: Tue Nov 08, 2005 4:29 pm

Post by 4Boredom »

ok but now its counting like this

19 = 0 + 10

the result should be 10
4Boredom
Forum Contributor
Posts: 176
Joined: Tue Nov 08, 2005 4:29 pm

Post by 4Boredom »

so yeah the first rowset is adding 9 to the result... the next is adding 10... the next 11... what is going on.. ahhhhh lol
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

Code: Select all

$totalvalue = $mysqlvalue + $addedvalue;
http://www.tizag.com/phpT/operators.php
Post Reply