Calculate SUM of a custom field

11 views
Skip to first unread message

Stéphan Herby

unread,
Jun 17, 2022, 4:12:25 PM6/17/22
to Joomla! General Development
Hi,
I have a directory for enterprises made with Seblod.
In each item, i have a fields "employees" with a number.
On header of the website, i have a module where the total of employees is printed.
I have wrote a PHP code (thanks to Sourcerer from Rgular :) ):

$query =
"SELECT SUM(directory_nbre_employees) FROM #__cck_store_form_directory         RIGHT JOIN #__content        ON #__cck_store_form_directorys.id=#__content.id        WHERE #__content.state='1' AND #__content.catid = '36' ";                  

$database->setQuery($query);        
$totalempl = $database->loadResult();


And it works well...

Today, I would like to migrate this directory to Joomla Items core (and no more Seblod).
I wonder if it is possible to have that same SUM but with a custom field.
Lets call this Text custom field "employees-number".
As I'm not a coder, i need some advice. Any intersted ?
Thanks in advance

Reply all
Reply to author
Forward
0 new messages