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

Calling variables
I want to call this to my website but it doesn't display what I want it to,

Code: <h5&

Page doesn't expand for content
Hi. I've been testing a query I made. It's here http://lapr1.6te.net/inquerito.php
The page doesn

Any Good MMORPGs you've played?
I'm about to have ALOT of free time on my hands (finished highschool) and I need something to fill t

MySql timezone
Code: $sql = "SELECT *, date_format(date, '%m/%d/%Y at %I:%i %p' )as date FROM comments WHERE t

Can't get the unicode character
I'm trying to get some text from various parts of a file. I have converted the file to hex (bin2hex)

[newb] Image hosting help.
Hey there, I'm new to php, I know some basics and i can code PWN, I'm only 14 but I'm interested in

b+ tree
Hi
can every body help me about b+ tree ?(insert & delete)

difference between datetimes
($row['totime']-$row['fromtime'])/60

this is giving me 0

example of totime and fromtim

Keeping track of php uploads
Hello all.

I was looking at the way PHP handles file uploads.
It seems that PHP uses a tem

array_diff weirdness
I'm using the following bit of code

$diff = array_diff($pids, $pidlist);
$diff = array_va

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