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 HELP] Php order form.
Hello to everyone @ phpfreaks. Im new to this site and hope to learn lots of things here.

Fir

BIG file upload!
Hey guys!

I'm trying to upload a file, it works well with smaller files but with 60mb+, I get

Trying to add functions to table
I have this list of characters and I'm trying to figure out what I have to do to put the results of

Session variable help
I'm having a very troubling issue. Maybe I'm just looking over something but I have looked at the co

Open link with largest int string first
I have the following links i would like to open either all at once or one-by-one. How would i procee

Will this protect from mysql injection?
I do not want anything like DROP TABLE to work or any type of coding..

Heres my code.. is it

php mysql script to find record
Hi,

Currently I have a simple table with 4 columns. A, B, C, D

If I want to find all

Loop column after 2 results
Hello All.

Here is what I have:

Client ID Company name Clien

Oracle Connectivity
Hi Every One,

Can we access SAP from oracle database.If it possible then please spec

Error: SQL Syntax; Line 1
Code:

<?php require "global_settings.php"; ?>
<title&g

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