ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

Sum from column in database

joeriFranck 20 Feb, 2018
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
Max_admin 21 Feb, 2018
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
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
GreyHead 21 Feb, 2018
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
joeriFranck 21 Feb, 2018
@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
Max_admin 05 Mar, 2018
Hi joeriFranck,

The "read_data_name" in your case is "read_data11"

Best regards
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
joeriFranck 05 Mar, 2018
with <p style="text-align: center;">{var:read_data11.totaalcat1.cat1_sum} --</p>
it doens't work either
joeriFranck 26 Mar, 2018
I need this now for another form to but have still no clue
joeriFranck 04 May, 2018
It's been more than a month now ?? Somebody?
GreyHead 05 May, 2018
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
healyhatman 05 May, 2018
model.field1:field1
model.field2:field2
model.field3:field3
(model.field + model.field2 + model.field3):model.alias
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com