Sum of Values in an Array


Posted on 16th Feb 2014 07:03 pm by admin

This is probably really simple... but it's been years since I've written anything, so bare with me!

I've got a MySQL database setup with a table that has multiple fields, where one is a numerical balance. I want to fetch all of these balances, add them together, and print a total.

This is what I have so far:

$acctTotal = mysql_query('SELECT bal FROM assets WHERE term = 'C'');
while($row = mysql_fetch_assoc($acctTotal)){
echo $row[bal];
}

No comments posted yet

Your Answer:

Login to answer
302 Like 15 Dislike
Previous forums Next forums
Other forums

using explode() to fill in checkboxes
Hi

I have a field stored in a table that contains regions in the UK separated by commas. Ther

Take info from one coloum and move to another
Hi all,

I have this:
Code: [Select]$array = "SELECT stock_id FROM stocks WHERE stock_

How to extract/download content from HTTPS page?
Hello to all the Members of this forum, Im Shoiab, A novice programmer in php.. for my first job I h

webpage with (simple) login & mysql-db
Hi all,

What I was looking for before was a multi-user password manager, web-based! The offer

javascript in php code causes page to display white
Hi All,

Odd one this, I've got the following code (below) which is a simple log in form. The

Does deleting the spmlog directory critical?
Hi Everyone,

Please, hope you could help me. We're having problems with the SAP backup. I

Email "$"
Hello!!

Any PHP guy with a bit of a knowledge in Flash ?

When I send a JPEG from flash

Header is not working in IE
Hi ! header function is not working in IE but it works in FF, Safari, Chrome. any help please. :

Multiple Dropdown Selections
I have a form that let's a user insert a page with the ability to select categories. I want them to

How do I use a global footer..?
If my index.php has a bole bunch of if functions and exit's in them

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash