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 & Images [Resize, Crop, Save]
Hey! Well I have a little dilema, hoping I could find some guidance.

I have a CMS and on the

Need a Timecode Class...
Not a Time Stamp, Time Code. Format is a bit different. HH:MM:SS:FF where FF is Frames. I dont re

How to store checkbox array in a session, and then be able to add to it?
I'm trying to store an array of checkbox values into a session array, sort of like a shopping cart,

problem getting my contact form working
Yeah I know this is a pretty basic problem, but it's been a while since I've worked with PHP and I'm

Undefined Index Notice In Internet Explorer Only
I am getting the following notice:

QuoteNotice: Undefined index: jrox in /home/ycsn/public_h

ORA-00932: inconsistent datatypes: expected - got CLOB
SO : windows xp
database : XE

there is a table (transito) with two fields of clob

Losing 'page' data
I have this code that allows me to update my database. But after updating, I lose the $_GET['page']

Get ID from Database when Posting with a HTML Form
I have a form I am submitting to a MySql database. Each product has an ID # attached to it that auto

need help in dynamic select menu in php
hi i have created a dynamic select menu using php. i have a problem in that which is when the user s

dinamic "textboxes"?
Ey all, my first post here, i hope its not a hard one

I display mysql results in a table

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