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

AJAX form submit
I recently built a form that submits data to my database with an ajax function that is called throug

PHP4 to PHP5 Conversion
Hi Everyone,

I am working on a site that is built up on PHP4 and each page is being started f

Different actions for different parts of a string
<?php
function dosomething($string, $else = '') {
if (empty($else))
$string

I am stumped
OK. Here is what I am trying to do. I have the conditions set, and if the conditions are met, I want

Format timestamp from mysql
When I tried this:
Code: date("m/d/Y H:i A", $row['timestamp'])
I got 12/31/1969 18:

Oracle Connectivity
Hi Every One,

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

send message to the java application
Oracle 10g with Windows platform.

I have a java application that periodically pings the d

IIS7 and getimagesize() problem
I have just discovered after hrs of trying to fix a problem where it's coming from. It's to do with

How can you detect variable string in a massive string?
Ok guys, i need some help with this one.

I am going to be getting a large string, like 10-20

Time script, set to my time zone?
I am using this line to get the date and time

Code: $time = date(F." ".d.", &q

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