I am new to PHP and Just learning as I go... Any help is GREATLY Appreciated.. This is probably simple....
I Need to get a total of one database field from multiple records.
Here is some code example..
<?php
include('variables.php');
$query = "SELECT * FROM accounts WHERE customerid = $customerid ";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$totaldue = total of $row[cost];
?>
Basic Function: Each customer may have several accounts active.. For each account there is a cost $row[cost] (perhaps different amounts depending on the type of account)
QUESTION: How do I get the total amount of $row[cost] ??
EXAMPLE:
Customerid: h12369 has 3 active accounts.. Each account has a different Value $row[cost]
Account #1 - $row [cost] = $5.00
Account #2 - $row[cost] = $10.00
Account #3 - $row[cost] = $3.00
CustomerID:h12369's TOTAL = $18.00 What is the code structure to get it to add up the cost fields and tell me the total is $18.00 .... ????
THANK YOU......