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

my login script page is not working on remote computers
hi my login is working on my computer, but when i tried 2 computers from 2 different locations, they

Not connecting to DB using ruby, error:env.c:257:in oci8lib.so: ORA-12154:
Hi All,

I am trying to connect to the database server from the client server using ruby and f

Delete records not in top 15
Hi,

I'm creating a hall of fame page in my game and the page will only display the top 15 sco

Inserting the current date/time while submitting the forum
What do I need to add below to update the current date/time? I have a field in the database called d

Strange php code found on my website
I got hacked and the following code was placed within my files:

Code: [Select]<?
/*

How to have a log of all the status a VIM document had been ?
Hi guys,

I’m using SAP Invoice Management plugin and the /OPT/VIM_ANALYTICS transa

php sessions,logouts & the bloomin back button!
Hi All,

I've got a cms that members can log into. When they logout, the session is destroyed,

search query in mysql in php problem
my search query wont work, i know, that my codes are correct.please help

Code: [Select]&l

please help me in this update statment
hi every one

if I have table and this data in it

id name
10

Update not working ... please help
Hi,

I am trying to update a row using an edit form by passing id of the row .. but it is not

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