Solved

calculating total in Dreamweaver mysql php

Posted on 2004-10-09
3
2,193 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:
adilkhan 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now