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

If statement help please.
Hello on my site I have 2 content boxes. 1 is for the main content (which is the biggest one) and th

A Few Questions
Hi, I want to ask a few questions that I can't seem to find..

1) I'm creating a "shortcu

Line break?
Hi, I'm new to the forum and new to php. I'm not sure if I'm using the correct terminology so here i

This is driving me nuts!
This insert query looks to be alright, however I get this error:

QuoteYou have an error in yo

Using Windows message as a Handle
Hi,

I am writing one of my first multithreaded programs.

In one of the thread,

Header is not working in IE
Hi ! header function is not working in IE but it works in FF, Safari, Chrome. any help please. :

problem when runing a funciton
I am trying to connect to database using a funciton in a functions.php

<?php
funct

upload photo limits
ive got a upload photo script and im just trying to make more secure currently it limits size and as

Gerenate tabel in Php
I whant to generate a tabel takeing data from database like this one so the results to be display on

need Array help
This is what I have to do.
$teamname[1] = "Red Sox"
$teamname[2] = "Gian

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