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, > Ken I discovered a good way for me: variables such as total only make sense within a [math] context, so then I want to 'print' the total -- outside the [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 items without 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:

    
  1. Re: Summing fields in a search/founditems context?? (Jason Tyler 2000)
  2. Summing fields in a search/founditems context?? (Robert McPeak 2000)
  3. Re: Summing Fields (Martin Gertz Bech 1998)
  4. Re: Summing Fields (Christer Olsson 1998)
  5. Summing Fields (Wayne Morishige 1998)
  6. Re: Summing fields (grichter@panavise.com (Gary Richter) 1997)
  7. Re: Summing fields (Grant Hulbert 1997)
  8. Re: Summing fields (Kenneth Grome 1997)
  9. Re: Summing fields (grichter@panavise.com (Gary Richter) 1997)
  10. Re: Summing fields (Grant Hulbert 1997)
  11. Re: Summing fields (Kenneth Grome 1997)
  12. Re: Summing fields (Britt T. 1997)
  13. Re: Summing fields (Grant Hulbert 1997)
  14. Re: Summing fields (Kenneth Grome 1997)
  15. Re: Summing fields (Grant Hulbert 1997)
  16. Re: Summing fields (Dean Smith 1997)
  17. Re: Summing fields (Dean Smith 1997)
  18. Re: Summing fields (Grant Hulbert 1997)
  19. Summing fields (Dean Smith 1997)
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, > Ken I discovered a good way for me: variables such as total only make sense within a [math] context, so then I want to 'print' the total -- outside the [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 items without 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:

Generating Options for a Form. (1997) redirect with frames (1997) dates and hex formatting (1997) Problem with imagemap variables (2006) How To question on setting up downloads (1997) I'm having trouble using [url][interpret][math] together in lookup (1997) [OT] What System Software? (2003) [searchString] (1997) Firewalls - What's Good? (1999) [ShowNext] feature in 2.0 (1997) Quitting WebMerchant ? (1997) [format 40s]text[/format] doesn't work (1997) [WebDNA] WebDNA and PHP cohabitating? (2009) Requiring that certain fields be completed (1997) Firesite and [referrer] atg broke (1997) WebCat hosting providers? (1997) Problem during evaluation of WebCatalog (1998) Error Type 3 (1999) Sorting problem (2002) REPLACE problem (2000)