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

natcasesort works on one server but not on another
Hi

I have a problem that I was hoping that someone can help me with.

I'm trying to use

Array question
Does anyone know how to create a program that takes the $ amount for 8 different departments and gi

SQL Injection
In my attempts to protect my database from mySQL injection I have created another problem for myself

Preventing SQL Injection
I have a question about SQL Injection, In some of our code we use this: view plaincopy to clipboa

$_GET problem
Hi all,

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

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,

How to change Time Zone
HI
I want to change the time zone of the server to another country.How can do that?

Thanks

Request.UrlReferrer
I need to make it so that a page can only be loaded when a button is clicked on a specific page. I d

why does my session end?
my connect.php starts the session just so you know
i can navigate arround my site fine except whe

parsing error
can anyone explain this syntax error:

Parse error: syntax error, unexpected T_IF

The e

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