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.

Did you know?Explore Trending and Topic pages for more stories like this.
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

PHP Surveys
I really would like some advice.

If you have a client come to you asking for a survey to be d

Passing vars to the DB
I have 3 small testing tables:

ID TYPE
1 pepperoni
2 C. bacon
3 taco

ID TY

Fetching array then reversing it
Hi, I have a simple problem, I'll try to explain it as best I can:
News entries in my database ar

no idea what to do...
I'm fed up. I had issues with code that I have working on a different site that didn't work on my cu

Calling strings from other php class
I have test1.php{
$string1;
$string2;
....
... //10 strings in this class <

Blank record injected into database
I always found several blank records inside my database, although $SESSION is required to insert the

$_GET problem
Hi all,

Have a bit of a problem with a little piece of code, I am not sure if this should be

help with email script...
hey

I need help with my mail script

when the form on http://www.mcgdesignstudio.com/c

Deleted Delivery but material wont return
We deleted a delivery but the material its still pending.

We made a reverse goods movemen

displaying email without attracting a ton of spam
Hello,

this is maybe the wrong place to ask.
How would you display an email address on a w

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