Buy Now
Sign in

Sum from column in database

joeriFranck , February 20 at 21:47
J
joeriFranck
Let me say I write items to a database. That works fine!
For example is save to database:
columns: name - cat1 - cat2 - cat3
cat1 cat2 and cat3 are all integers
I want to display the sum of each column to the site.
Can that be done, I found helpitems for this from 2010 but they don't work anymore.
Kind regards
admin
Hi Joeri,
You will need to use a "Read data" action and in the "Field to retrieve" box use:
SUM(cat1):cat1_sum
Then you can extract the result using a shortcode, if your "Select type" is set to "first matching" then you need something like this:
{var:read_data_name.Model_name.cat1_sum}
Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
GreyHead
Hi joeriFranck ,
It's not simple to sum values in the same row using MySQL so probably the best solution is to use a Custom Code or PHP action after you load the data, calculate the total and add it to your form data as a new entry.
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
J
joeriFranck
@admin: i did this:
knipsel1.JPG
and then this:
knipsel2.JPG
That doens't work in frontend there is no result.
At greyhead, only the columns is good for me
Attachments
knipsel1.JPG
knipsel1.JPG
(95.6 KiB)
243 Downloads/Views
knipsel2.JPG
knipsel2.JPG
(68.95 KiB)
227 Downloads/Views
admin
Hi joeriFranck,
The "read_data_name" in your case is "read_data11"
Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
J
joeriFranck
with <p style="text-align: center;">{var:read_data11.totaalcat1.cat1_sum} --</p>
it doens't work either
J
joeriFranck
Still no sollution,..
J
joeriFranck
I need this now for another form to but have still no clue
J
joeriFranck
It's been more than a month now ?? Somebody?
GreyHead
Hi JoeriFranck,
You said that the column names were cat1, . . . but in one of your images you have SUM(_catagorie1) . . . is that correct? It would be unusual to have a column name starting with an underscore?
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
H
healyhatman
model.field1:field1
model.field2:field2
model.field3:field3
(model.field + model.field2 + model.field3):model.alias
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman