Hi
I have searched for an answer to this for some time now but my php-knowledge is very slim.
Instead, I'm now reaching out to the community for help.
I have "content_type_a" where I store numeric values in "field_1", "field_2" & "field_3".
In a different content type (content_type_b) I'm trying to use a computed field to sum all values in field_3 of content_type_a nodes for all nodes posted by the active user.
Then store and print the sum.
What I got so far is something like this:
$result = db_query('SELECT SUM(field_3) FROM {content_type_a} WHERE uid = current user');
$entity_field[0]['value'] = $result;
$display_output = $entity_field_item['value'];
I've tried getting a result without specifying wich user posted the node but still no luck.
Any help with this would be appreciated.
I'm using drupal 7.
/Andreas
Comments
Comment #1
Arvika CreditAttribution: Arvika commentedI managed to sum the fields I wanted using the following code:
These fields are all in the same table (field_data_field_result), but how do i filter this result to sum only fields from nodes of a specific user?