Re: Summing fields
This WebDNA talk-list message is from 1997
It keeps the original formatting.
numero = 10810
interpreted = N
texte = Kenneth Grome wrote:> > >> >I think it was mentioned once that it is possible to calculate a total> >> >for a particular field over records in a database. What is the syntax> >> >for doing this?> >>> >> <--starts a total variable at 0> >> [FoundItems]> >> > >> [/FoundItems]> >>> >> If you view source you will see this generates a lot of HTML comments> >>like with the intermediate results. You might also try> >>> >> [math]total=[FoundItems][field]+[/FoundItems]0[/math]> >>> >> This generates a single math equation that looks like total=5+9+4+49+7+96+0> > >Apparently both methods work cause I see the 's. The second> >displayed the total as I wanted. How would I get the total to display> >using the first method?> > If you remove the that surround the [math] context, it will> display all those intermediate totals. But if you want to display the grand> total instead of the intermediate totals, you have to use the second> formula, or ...> > I created some WebDNA code using a separate database to calculate the total> just once per day. This allows me to retrieve the total from the database> instead of recalculating it every time. If you want my code, just send me> private email and ask ... :)> > Sincerely,> KenI discovered a good way for me: variables such as total only make sensewithin a [math] context, so then I want to 'print' the total -- outsidethe [foundItems]...[/foundItems] loop, I express it as[math]total[/math]. That works quite well. I am doing this so that I can allow people to shop and select itemswithout going to the shopping cart. As soon as I get it all completed,I will share the templates.Dean Smith
Associated Messages, from the most recent to the oldest:
Kenneth Grome wrote:> > >> >I think it was mentioned once that it is possible to calculate a total> >> >for a particular field over records in a database. What is the syntax> >> >for doing this?> >>> >> [math]total=0[/math]> <--starts a total variable at 0> >>
[founditems]> >> [math]total=total+[field][/math]>> >> [/FoundItems]> >>> >> If you view source you will see this generates a lot of HTML comments> >>like with the intermediate results. You might also try> >>> >>
[math]total=
[founditems][field]+[/FoundItems]0[/math]> >>> >> This generates a single math equation that looks like total=5+9+4+49+7+96+0> > >Apparently both methods work cause I see the 's. The second> >displayed the total as I wanted. How would I get the total to display> >using the first method?> > If you remove the that surround the
[math] context, it will> display all those intermediate totals. But if you want to display the grand> total instead of the intermediate totals, you have to use the second> formula, or ...> > I created some WebDNA code using a separate database to calculate the total> just once per day. This allows me to retrieve the total from the database> instead of recalculating it every time. If you want my code, just send me> private email and ask ... :)> > Sincerely,> KenI discovered a good way for me: variables such as total only make sensewithin a
[math] context, so then I want to 'print' the total -- outsidethe
[founditems]...[/foundItems] loop, I express it as
[math]total[/math]. That works quite well. I am doing this so that I can allow people to shop and select itemswithout going to the shopping cart. As soon as I get it all completed,I will share the templates.Dean Smith
Dean Smith
DOWNLOAD WEBDNA NOW!
Top Articles:
Talk List
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...
Related Readings:
Announcement-WebCatalog 2.0 Released (1997)
Interactive Online Docs Was: [OT] Mozilla | Was: R.I.P. (2003)
[/application] error? (1997)
[WebDNA] email validation (2019)
Okay, I give up... (1999)
Prevent multiple appends with Reload Button (1997)
WC 4.0 on Solaris - can't 'find' admin templates (2000)
cookie problems (1999)
Running _every_ page through WebCat-error.html (1997)
Problem with [Search] inside of [Loop]? (1997)
Pull down menu for categories (2000)
Associative lookup style? + bit more (1997)
Taxable Shipping (2003)
Funny Math (2000)
[OT] ODBC between IIS and remote Access problem (2000)
Email notification to one of multiple vendors ? (1997)
Globals folders (2004)
[WebDNA] File uploads using WebDNA (2010)
WebStar SSL and WebCatalog conflict? (1999)
Just Testing (1997)