###### Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

Deciding to stick with EE.

Mohamed Asif

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
###### Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

# How do i sum a variable in php?

PHP
The variable is in fact a pseudo column that contains a mathematical formula as follows

``````SELECT (((kinisis_1c + kinisis_1e + ((kinisis_1c / kinisis_1b) * kinisis_1a))/(1 + fpa)) * 1.005) AS kinisis_1_total, (((100c + 100e + ((100c / 100b)* 100a)) / (1 + fpa)) *1.005) AS 100ara_total, (((super_1c  + super_1e + ((super_1c / super_1b)* super_1a)) / (1 + fpa)) *1.005) AS super_1_total, (((95_1c + 95_1e + ((95_1c / 95_1b)* 95_1a)) / (1 + fpa)) *1.005) AS 95_1_total, (((95_2c + 95_2e + ((95_2c / 95_2b)*  95_2a)) / (1 + fpa)) *1.005) AS 95_2_total, (((super_2c + super_2e + ((super_2c / super_2b) * super_2a)) / (1 + fpa)) *1.005) AS super_2_total, (((kinisis_2c + kinisis_2e + ((kinisis_2c / kinisis_2b) * kinisis_2a)) / (1 + fpa)) *1.005) AS kinisis_2_total
FROM kiniseis
WHERE `date` BETWEEN '\$_GET[date1]' AND '\$_GET[date2]'
``````

I made the query without sum inside it cause was creating big precision  problems.So i thought to let php to make the sum , while pulling the data from the mysql query.

For example the variable in php to be like this :
\$i1 = SUM('\$row_i_totals[kinisis_1_total]');
echo \$i1

But i dont know the syntax to output the correct sum in php , cause this is a string and have no idea how to format it. Preferably a decimal number cause it outputs money value.

Can  you tell me pls how to do it?
Thank you :)