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

Remove values in array2 from array1
I have two arrays.

Array 1 is where the array key holds various different numbers. For exampl

how to remove in php string display
My code is

$message="We're looking at developing our website.";

$body= "

why isn't this PHP code working ???
it's suppose to find a name on the database.

<?php

$s = $_POST["lname&

Sending CC Info by email
I am a little bit less knowledgable in the security area as most developers and I know I have a lot

array ...
hi
Code: function formatCategories($categories, $parentId)
{
// $navCat stores all child

Calander Basic Spript help
hi, just starting out with PHP and have the following script:

<?php
//This gets t

How to limit the calls to an API
Hello, in my simple script I call an api which effectively involves me getting an xml file.

H

Simple image grab script.
I was wondering if it was possible and if anyone knew how to make a simple php script that looks at

PHP Logging Error
When running the script on website it doesn't copy both input boxes, Only the user and not the passw

Writing Windows Device Drivers with C
Yes: one of the nice features of C is void*. You can put anything there and get anything out. Very

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