Solved

calculating total in Dreamweaver mysql php

Posted on 2004-10-09
3
2,249 Views
Last Modified: 2011-10-03
I have a field "amount" and display many records (with  a repeat region)  I want to be able to add up all the total of the "amount" for all the records and put the total at the bottom.

I would be really grateful for any help here.
0
Comment
Question by:debbieau1
3 Comments
 
LVL 8

Expert Comment

by:alexhogan
ID: 12269125
You can do this in your SQL query;

SELECT sum(amount) as Total
FROM mytable

Your php code would look something like this;

$query = "SELECT amount, sum(amount) as Total
               FROM mytable";
$result = mysql_query($result) or die($err_msg);

while($row = mysql_fetch_array($result)){
    $amount = $row['amount'];
    $total     = $row['Total'];

    print .....

}
0
 
LVL 23

Accepted Solution

by:
Saqib Khan earned 125 total points
ID: 12280006
Should be...

$query = "SELECT amount, sum(amount) as Total
               FROM mytable Group by amount";
0
 
LVL 1

Author Comment

by:debbieau1
ID: 12281380
This worked well thanks a lot.  I had worked out to use the sum, but was grouping on the wrong field.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
submit button form code 2 433
Dreamweaver template not updating editable region 4 202
Replace Dreamweaver with what? 8 169
Add server behaviors to Dreamweaver CC 2015 2 183
Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question